Yes but how do you set that hidden field if the checkbox value changes?
You must also use javascript then i believe

johan

----- Original Message ----- 
From: "Howard Moore" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 22, 2001 11:04 AM
Subject: RE: Support for submitting unchecked checkboxes


> One problem with this is that it fails if javascript is disabled on the
> client.
> 
> An alternative hack would be to have a hidden field and the checkbox both
> with the same name  and have Struts process them as a special case when
> populating the ActionForm.
> 
> > -----Original Message-----
> > From: Johan Compagner [mailto:[EMAIL PROTECTED]]
> > Sent: 22 February 2001 09:03
> > To: [EMAIL PROTECTED]
> > Subject: Re: Support for submitting unchecked checkboxes
> > 
> > 
> > +1
> > 
> > Please insert this (or something like this) in the 1.0 code 
> > base, because
> > checkboxes are useless at this time to use!!
> > 
> > johan
> > 
> > ----- Original Message -----
> > From: "Laine Donlan" <[EMAIL PROTECTED]>
> > To: "Struts Dev (E-mail)" <[EMAIL PROTECTED]>
> > Sent: Tuesday, February 20, 2001 2:19 PM
> > Subject: Support for submitting unchecked checkboxes
> > 
> > 
> > In order to capture the act of a user unchecking checkboxes and to
> > initialize the checkbox as checked/unchecked with non boolean values I
> > made a couple of changes to the
> > org.apache.struts.taglib.html.CheckboxTag.
> > 
> > Basically the changes consisted of:
> > 
> > 1) Using the supplied value attribute to match against the 
> > bean property
> > value and generating the 'checked' attribute accordingly.  If 
> > the value
> > is not supplied then the previously implemented method of 
> > checking 'on',
> > 'true', or 'yes' is performed.  So I do not think that 
> > default behavior
> > should be affected.
> > 
> > 2) Added support for two new attributes - submitUnchecked 
> > (boolean) and
> > uncheckedValue (String).  Neither of these attributes are required and
> > the submitUnchecked defaults to 'false'.  If a user chooses to submit
> > unchecked values then two form inputs will be generated that 
> > facilitate
> > this function.  See below for an example:
> > 
> > Tag notation -
> > <html:checkbox  name="bean" property="indexedBean.property"
> > submitUnchecked="true" uncheckedValue="0" value="1"/>
> > 
> > Generated HTML -
> > <input type="checkbox" name="indexedBean.property_checkBox" value="1"
> > 
> > onclick="(this.checked?this.form['indexedBean.property'].value
> > ='1':this.
> > form['indexedBean.property'].value='0')">
> > <input type="hidden" name="indexedBean.property" value="0"/> 
> > (where 0 is
> > the current value of the bean property)
> > 
> > So in this scenario the actual checkbox param in the request will be
> > ignored and the hidden input will be used to maintain the 
> > bean property
> > that the user wishes.
> > 
> > In the case where the user does not provide the two new attributes the
> > html will be generated as it is today with the exception of the
> > determination of the checked or unchecked mentioned above.
> > 
> > I could not see how this functionality was present in the current
> > checkbox tag without explicitly declaring two tags and adding 
> > javascript
> > to the checkbox tag.  Even then some scripting may be required to
> > differentiate between the two inputs and to initialize the hidden one.
> > If I missed something could someone point me in the right 
> > direction.  I
> > have attached the CheckboxTag.java file for review and use if 
> > anyone is
> > interested.
> >  <<CheckboxTag.zip>>
> > Thanks.  Comments would be appreciated.
> > 
> > Laine
> > 
> > 
> 

Reply via email to