[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-user
Subject:    Re: checkbox on indexed form field
From:       "Matt Bathje" <mpb () ntsource ! com>
Date:       2004-06-01 13:34:06
Message-ID: 00d701c447dd$1d164600$9501a8c0 () mpb
[Download RAW message or body]

I actually found a much better way to do this. If you have a hidden form
field with a blank value that you name the same thing as your checkbox, then
something always gets passed with the form. If you don't have the checkbox
checked, then just a blank field with that name gets passed. If the checkbox
is checked, then the proper value is checked. It is a very slick solution to
this problem I think.

A simplistic version of this for anybody who didn't understand my
explanation:

<html:checkbox name="testName" property="testProp" indexed="true" />
<html:hidden name="testName" property="testProp" indexed="true" value="" />

I assume this would work the same if you weren't using indexed properties as
well.


Matt Bathje
----- Original Message ----- 
From: <hermod.opstvedt@dnbnor.no>
To: <user@struts.apache.org>
Sent: Thursday, May 27, 2004 5:09 AM
Subject: SV: checkbox on indexed form field


> Hi
>
> You need to implement the reset() method on your ActionForm and in that
> setting any boolean variables to null. When you submit from a form, any
> unchecked checkboxes are not sent - only checked ones. Therefor the
> reset to set them to false initially, and if someon checks them they
> will be set to true.
>
> Hermod
>
> -----Opprinnelig melding-----
> Fra: Matt Bathje [mailto:mpb@ntsource.com]
> Sendt: 26. mai 2004 00:41
> Til: Struts Users Mailing List
> Emne: checkbox on indexed form field
>
>
> Hey all.
>
> I have an indexed form with data that looks like this:
>
> checkbox1, textbox1_1, textbox1_2
> checkbox2, textbox2_1, textbox2_2
> checkbox3, textbox3_1, textbox3_2
> etc.
>
> The checkbox is used to mark that "row" active or inactive.
>
> If the checkbox is unchecked, and I check it, the row becomes "active"
> in
> the database properly.
>
> But, if the checkbox is checked, and I uncheck it, the row does not get
> marked "inactive" in the database. I can't figure out how to get this
> done.
>
> In the bean for the data, active is a boolean property that defaults to
> false. (This is what I thought would be the default for an unchecked
> checkbox, but it isn't working)
>
> I am using a dynavalidatorform if that makes any difference.
>
>
> Anybody have any idea? or need more information/clarification.
>
> Thanks,
> Matt Bathje
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
>
> This email with attachments is solely for the use of the individual or
> entity to whom it is addressed. Please also be aware that DnB NOR cannot
> accept any payment orders or other legally binding correspondence with
> customers as a part of an email.
>
> This email message has been virus checked by the virus programs used
> in the DnB NOR Group.
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic