BONNET Francois-Xavier wrote:

>You don't even need javascript :
>I have modified checkboxTag to generate a hidden field with the same name that the 
>checkbox and value false. As Struts BeanUtils.populate(...) method takes first value 
>found in the request to populate the field in the ActionForm, i just had to put the 
>hidden field after the checkbox.
>It seems to work fine, no javascript and other developpers on my project do not have 
>to 
>worry about it anymore.
>
>Francois-Xavier Bonnet
> 
>----- Original Message -----
>From: Dan Cancro <[EMAIL PROTECTED]>
>Date: Monday, December 17, 2001 6:41 pm
>Subject: RE: Checkbox's question.
>
>>I was just thinking about this problem, too.  I think this
>>checkbox-in-request-only-when-checked anomaly should be handled with
>>javascript like this:
>>
>>The checkbox jsp tag should create a hidden field named after the property,
>>and a checkbox with some other name.  When the checkbox is checked or
>>unchecked, it should change the value of the hidden field with a generated
>>line of javascript.
>>
>>This way, the controller doesn't have to know that the field is rendered as
>>a checkbox (and do this special checkbox jig), and the field's value is only
>>changed when the field exists in the request.  So if another jsp doesn't
>>have the checkbox at all, the value isn't touched.
>>
>>Dan
>>
>>>-----Original Message-----
>>>From: Linnea Ahlbeck [mailto:[EMAIL PROTECTED]]
>>>Sent: Monday, December 17, 2001 10:29 AM
>>>To: Struts Users Mailing List
>>>Subject: Re: Checkbox's question.
>>>
>>>
>>>Hi!!
>>>
>>>All values from your formbean are sent in the request as 
>>>parameters when you
>>>press submit - but checkbox values are only in this request 
>>>if they have the
>>>value on = they are checked. If you use the reset method it 
>>>should work in a
>>>correct way  -  values are first set to false by the reset 
>>>method and then,
>>>if they are present i the request they receive value true, 
>>>otherwise the
>>>have the value false. /Linnéa
>>>
>>>
>>>
>>>----- Original Message -----
>>>From: <[EMAIL PROTECTED]>
>>>To: <[EMAIL PROTECTED]>
>>>Sent: Monday, December 17, 2001 7:07 PM
>>>Subject: RE: Checkbox's question.
>>>
>>>
>>>coincidentally, I was working on the check box today for the 
>>>first time. I
>>>found the problem too.
>>>It seems OK when you set the check box "unchecked" as defaut
>>>(openWindow=null;). but when you set it "checked" as default, 
>>>each time you
>>>uncheck the box and submit. the value won't change, it still remained
>>>checked. In fact. the setOpenWindow(..) function has never 
>>>been called when
>>>the box was unchecked. It is only called when the check box 
>>>is checked.
>>>Any one knows what went wrong?
>>>
>>>Thanks
>>>
>>>Yunming Li
>>>
>>>-----Original Message-----
>>>From: Linnea Ahlbeck [mailto:[EMAIL PROTECTED]]
>>>Sent: Monday, December 17, 2001 11:51 AM
>>>To: Struts Users Mailing List
>>>Subject: Re: Checkbox's question.
>>>
>>>
>>>Hi!
>>>
>>>Use the reset method in the form bean:
>>>
>>>public void reset(ActionMapping mapping, HttpServletRequest request) {
>>>      openWindow= false;
>>> }
>>>
>>>This is a well known problem, see link:
>>>http://www.jguru.com/faq/view.jsp?EID=471957
>>>
>>>Good luck / Linnéa
>>>
>>>
>>>----- Original Message -----
>>>From: "Hong Xing" <[EMAIL PROTECTED]>
>>>To: <[EMAIL PROTECTED]>
>>>Sent: Monday, December 17, 2001 4:05 PM
>>>Subject: Checkbox's question.
>>>
>>>
>>>Hi all,
>>>I am a newbie.
>>>I used <html:checkbox> in my work. But it worked strange. When I
>>>first view the page and submit the form, the checkbox is OK. Then if I
>>>view the page again and change the checkbox's state, the 
>>>checkbox is not
>>>ok. It's always checked. How to fix it?
>>><html:checkbox property="openWindow" value="on"/>
>>>
>>>public void setOpenWindow(String openWindow)
>>>{
>>>this.openWindow=openWindow;
>>>}
>>>public String getOpenWindow()
>>>{
>>>return openWindow;
>>>}
>>>private String openWindow="on";
>>>
>>>Please help me!!!
>>>
>>>Sincerely, Hong Xing
>>>
>>>
>>>==============================
>>>Bioinformatics Department
>>>Beijing Genomics Institute
>>>Beijing Center
>>>Beijing Airport Industrial Zone B6
>>>Beijing 101300
>>>Tel: 0086-10-80494199-3306(Office)
>>>Email : [EMAIL PROTECTED]
>>>==============================
>>>
>>>
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>>For additional commands, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>>
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>>For additional commands, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:   
>>>
>><mailto:[EMAIL PROTECTED]>
>>For additional commands, e-mail:
>><mailto:[EMAIL PROTECTED]>
>>
>>--
>>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>>
>>
>
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
>
Francois,

Could you post the changes you made to the checkBoxTag to the Struts dev group so it 
can reviewed and possibly added to the next version of the taglibs?  Hey, that's what 
open source is all about. :)

Barry
 



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to