Checkbox problem
Hi Group, I am using Struts 1.1 version. I have a page in which i display a set of checkboxes(10 checkboxes to be specific). All the checkboxes have the same name and have different values. I have an ActionForm for this. In the ActionForm, i have a String[] checkBoxArr to represent these checkboxes. I have a condition that i have to check one particular checkbox out of the ten. Some said to set this in the constructor. Please suggest a way for doing this. Many Thanks, Janarthan S - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it!
RE: Checkbox problem?
Oki, thanks for all your suggestions; I'll try them out and see what happens... :) BTJ On Tue, 2003-06-10 at 22:11, Steve Raeburn wrote: The suggested method requires two actions. SetupAction - Form - ProcessAction The first action prepares any values required by your form, including setting the value of your checkboxes to true. The second action is the one that actually processes the user input gathered by the form. Hope this clarifies things. Steve -Original Message- From: Bjørn T Johansen [mailto:[EMAIL PROTECTED] Sent: June 10, 2003 12:38 PM To: Struts Users Mailing List Subject: Re: Checkbox problem? oki, maybe my explanation isn't the best :) (I know that I can't do it in the reset method, as it is clearly not working) but I am still not sure where to put the code to set the checkbox to true then. As far as I know, the action class isn't called before after the form bean has called the reset method and the page has been rendered (and the submit button has been pressed), or is it something I am missing? BTJ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Checkbox problem?
I use checkboxes to input some variables in a form and as long as I insert new records, i.e. the checkbox variable gets set to false in the form's reset method, it works fine. But when I, say, edit the same record (and propagate the values of the form in the reset method), I never can uncheck the checkbox if it was set to true in the reset method. Are there any solutions/work around for this? Regards, BTJ --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Antwort: Checkbox problem?
The reset-method is called if you are submitting from a jsp-page. You must check the browser request, if a value exists. If a value is missing, the user has unchecked the box, so you can set the record to false. Cheers, Manuel |-+ | || | || | || | |Bjorn T Johansen | | |[EMAIL PROTECTED]| | |10.06.2003 10:26| | |Bitte antworten an Struts | | |Users Mailing List | | || |-+ | | | | An: [EMAIL PROTECTED] | | Kopie: | | Thema: Checkbox problem? | | I use checkboxes to input some variables in a form and as long as I insert new records, i.e. the checkbox variable gets set to false in the form's reset method, it works fine. But when I, say, edit the same record (and propagate the values of the form in the reset method), I never can uncheck the checkbox if it was set to true in the reset method. Are there any solutions/work around for this? Regards, BTJ --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkbox problem?
Can you describe what's going on in more detail? -- James Mitchell Software Developer/Struts Evangelist http://www.struts-atlanta.org - Original Message - From: Bjorn T Johansen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 4:26 AM Subject: Checkbox problem? I use checkboxes to input some variables in a form and as long as I insert new records, i.e. the checkbox variable gets set to false in the form's reset method, it works fine. But when I, say, edit the same record (and propagate the values of the form in the reset method), I never can uncheck the checkbox if it was set to true in the reset method. Are there any solutions/work around for this? Regards, BTJ -- - Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no -- - The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. -- - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox problem?
I would suggest not doing the propagate in the reset. Just use it for the original values. The values entered on the form are automatically propagated by struts after the reset by the setters and getters. Just put in some logging or print statements in those methods and you will see when they are invoked. -Original Message- From: Bjorn T Johansen [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 4:27 AM To: [EMAIL PROTECTED] Subject: Checkbox problem? I use checkboxes to input some variables in a form and as long as I insert new records, i.e. the checkbox variable gets set to false in the form's reset method, it works fine. But when I, say, edit the same record (and propagate the values of the form in the reset method), I never can uncheck the checkbox if it was set to true in the reset method. Are there any solutions/work around for this? Regards, BTJ --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox problem?
I had some issues with the methods, so I came up with something else that works very nicely. In the JSP, right after the code for the checkbox, use: jsp:setProperty name=beanName property=checkboxProperty value=false / This allows the form submission to work correctly, without any messy code. However, I am no expert with this stuff, so if there is any reason not to do this I'd be interested in hearing it. Keith Kamholz Programming and Architecture Moog Inc. Phone: (716) 687-7001 -Original Message- From: Bjorn T Johansen [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 4:27 AM To: [EMAIL PROTECTED] Subject: Checkbox problem? I use checkboxes to input some variables in a form and as long as I insert new records, i.e. the checkbox variable gets set to false in the form's reset method, it works fine. But when I, say, edit the same record (and propagate the values of the form in the reset method), I never can uncheck the checkbox if it was set to true in the reset method. Are there any solutions/work around for this? Regards, BTJ --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox problem?
Yes, but to clarify... I am showing a jsp page with values read from a database. If the checkbox value is true, how do I then make the checkbox on my jsp-page checked and how do I then find out if the checkbox has been unchecked? Do I have to manually read the posted data and see if the checkbox attribute is missing or is there a better way? BTJ On Tue, 2003-06-10 at 15:45, Kandi Potter wrote: I would suggest not doing the propagate in the reset. Just use it for the original values. The values entered on the form are automatically propagated by struts after the reset by the setters and getters. Just put in some logging or print statements in those methods and you will see when they are invoked. -Original Message- From: Bjorn T Johansen [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 4:27 AM To: [EMAIL PROTECTED] Subject: Checkbox problem? I use checkboxes to input some variables in a form and as long as I insert new records, i.e. the checkbox variable gets set to false in the form's reset method, it works fine. But when I, say, edit the same record (and propagate the values of the form in the reset method), I never can uncheck the checkbox if it was set to true in the reset method. Are there any solutions/work around for this? Regards, BTJ --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox problem?
In your ActionForm reset() method, set the checkbox value to false. Struts will set the value to true if the box is checked. If you are using DynaForms, you will need to extend it and override the reset() method. To populate the checkbox initially, you need to instantiate and populate the form bean and place it in the appropraite context. For more details, see: http://jakarta.apache.org/struts/faqs/newbie.html#prepopulate http://jakarta.apache.org/struts/faqs/newbie.html#checkbox -Kevin --- Bjørn T Johansen [EMAIL PROTECTED] wrote: Yes, but to clarify... I am showing a jsp page with values read from a database. If the checkbox value is true, how do I then make the checkbox on my jsp-page checked and how do I then find out if the checkbox has been unchecked? Do I have to manually read the posted data and see if the checkbox attribute is missing or is there a better way? BTJ On Tue, 2003-06-10 at 15:45, Kandi Potter wrote: I would suggest not doing the propagate in the reset. Just use it for the original values. The values entered on the form are automatically propagated by struts after the reset by the setters and getters. Just put in some logging or print statements in those methods and you will see when they are invoked. -Original Message- From: Bjorn T Johansen [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 4:27 AM To: [EMAIL PROTECTED] Subject: Checkbox problem? I use checkboxes to input some variables in a form and as long as I insert new records, i.e. the checkbox variable gets set to false in the form's reset method, it works fine. But when I, say, edit the same record (and propagate the values of the form in the reset method), I never can uncheck the checkbox if it was set to true in the reset method. Are there any solutions/work around for this? Regards, BTJ --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkbox problem?
[EMAIL PROTECTED] | Yes, but to clarify... | I am showing a jsp page with values read from a database. If the | checkbox value is true, how do I then make the checkbox on my jsp-page | checked and how do I then find out if the checkbox has been unchecked? | Do I have to manually read the posted data and see if the checkbox | attribute is missing or is there a better way? I assume that you are using an Action with an ActionForm. To make the value of the checkbox come up correctly, import struts tags into your jsp-page: %@ taglib uri=/WEB-INF/struts-bean.tld prefix=strb % %@ taglib uri=/WEB-INF/struts-html.tld prefix=strh % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=strl % Then use the Struts checkbox tag: strh:checkbox property=done/ Assuming that your form has the methods getDone and setDone, these methods will be used to render the value of the checkbox correctly. As to the question of boolean values that are set to false by the user: You don't have to parse the posted data manually. The method reset() in ActionForm is run before the posted data is used to populate the form. Write your own reset() method where you set the boolean fields to false. -- mvh Tor Henrik Hanken - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkbox problem?
You are missing my point! If I just could set the checkbox value to false in the reset method, everything is fine. But there are times when that value has to be reset to true and not false and if I do that in my reset method, I am not able to see of the user unchek the checkbox, because the boolean variable is still true after the form has been posted! BTJ On Tue, 2003-06-10 at 19:22, Tor Henrik Hanken wrote: [EMAIL PROTECTED] | Yes, but to clarify... | I am showing a jsp page with values read from a database. If the | checkbox value is true, how do I then make the checkbox on my jsp-page | checked and how do I then find out if the checkbox has been unchecked? | Do I have to manually read the posted data and see if the checkbox | attribute is missing or is there a better way? I assume that you are using an Action with an ActionForm. To make the value of the checkbox come up correctly, import struts tags into your jsp-page: %@ taglib uri=/WEB-INF/struts-bean.tld prefix=strb % %@ taglib uri=/WEB-INF/struts-html.tld prefix=strh % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=strl % Then use the Struts checkbox tag: strh:checkbox property=done/ Assuming that your form has the methods getDone and setDone, these methods will be used to render the value of the checkbox correctly. As to the question of boolean values that are set to false by the user: You don't have to parse the posted data manually. The method reset() in ActionForm is run before the posted data is used to populate the form. Write your own reset() method where you set the boolean fields to false. -- --- Bjørn T Johansen (BSc,MNIF) Executive Manager [EMAIL PROTECTED] Havleik Consulting Phone : +47 67 54 15 17 Conradisvei 4 Fax : +47 67 54 13 91 N-1338 Sandvika Cellular : +47 926 93 298 http://www.havleik.no --- The stickers on the side of the box said Supported Platforms: Windows 98, Windows NT 4.0, Windows 2000 or better, so clearly Linux was a supported platform. --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkbox problem?
On Tuesday 10 June 2003 14:11, Bjørn T Johansen wrote: You are missing my point! If I just could set the checkbox value to false in the reset method, everything is fine. But there are times when that value has to be reset to true and not false and if I do that in my reset method, I am not able to see of the user unchek the checkbox, because the boolean variable is still true after the form has been posted! No, actually *YOU* are missing the point! Several people have tried to explain how this works to you. So, for one last effort IMPORTANT DO *NOT* SET THE FIELDS YOU INTENT TO USE AS CHECKBOXES (booleans) TO TRUE IN THE RESET METHOD! /IMPORTANT If you want the field to be true when the page is rendered, set it to true from your action class, NOT in the reset of your formbean. I hope that clears it up for you. BTJ On Tue, 2003-06-10 at 19:22, Tor Henrik Hanken wrote: [EMAIL PROTECTED] | Yes, but to clarify... | I am showing a jsp page with values read from a database. If the | checkbox value is true, how do I then make the checkbox on my jsp-page | checked and how do I then find out if the checkbox has been unchecked? | Do I have to manually read the posted data and see if the checkbox | attribute is missing or is there a better way? I assume that you are using an Action with an ActionForm. To make the value of the checkbox come up correctly, import struts tags into your jsp-page: %@ taglib uri=/WEB-INF/struts-bean.tld prefix=strb % %@ taglib uri=/WEB-INF/struts-html.tld prefix=strh % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=strl % Then use the Struts checkbox tag: strh:checkbox property=done/ Assuming that your form has the methods getDone and setDone, these methods will be used to render the value of the checkbox correctly. As to the question of boolean values that are set to false by the user: You don't have to parse the posted data manually. The method reset() in ActionForm is run before the posted data is used to populate the form. Write your own reset() method where you set the boolean fields to false. -- James Mitchell Software Developer/Struts Evangelist http://www.struts-atlanta.org 770-822-3359 AIM:jmitchtx - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox problem?
Go get 'em, James! -Original Message- From: James Mitchell [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 2:29 PM To: Struts Users Mailing List Subject: Re: Checkbox problem? On Tuesday 10 June 2003 14:11, Bjørn T Johansen wrote: You are missing my point! If I just could set the checkbox value to false in the reset method, everything is fine. But there are times when that value has to be reset to true and not false and if I do that in my reset method, I am not able to see of the user unchek the checkbox, because the boolean variable is still true after the form has been posted! No, actually *YOU* are missing the point! Several people have tried to explain how this works to you. So, for one last effort IMPORTANT DO *NOT* SET THE FIELDS YOU INTENT TO USE AS CHECKBOXES (booleans) TO TRUE IN THE RESET METHOD! /IMPORTANT If you want the field to be true when the page is rendered, set it to true from your action class, NOT in the reset of your formbean. I hope that clears it up for you. BTJ On Tue, 2003-06-10 at 19:22, Tor Henrik Hanken wrote: [EMAIL PROTECTED] | Yes, but to clarify... | I am showing a jsp page with values read from a database. If the | checkbox value is true, how do I then make the checkbox on my | jsp-page checked and how do I then find out if the checkbox has | been unchecked? Do I have to manually read the posted data and see | if the checkbox attribute is missing or is there a better way? I assume that you are using an Action with an ActionForm. To make the value of the checkbox come up correctly, import struts tags into your jsp-page: %@ taglib uri=/WEB-INF/struts-bean.tld prefix=strb % %@ taglib uri=/WEB-INF/struts-html.tld prefix=strh % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=strl % Then use the Struts checkbox tag: strh:checkbox property=done/ Assuming that your form has the methods getDone and setDone, these methods will be used to render the value of the checkbox correctly. As to the question of boolean values that are set to false by the user: You don't have to parse the posted data manually. The method reset() in ActionForm is run before the posted data is used to populate the form. Write your own reset() method where you set the boolean fields to false. -- James Mitchell Software Developer/Struts Evangelist http://www.struts-atlanta.org 770-822-3359 AIM:jmitchtx - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkbox problem?
oki, maybe my explanation isn't the best :) (I know that I can't do it in the reset method, as it is clearly not working) but I am still not sure where to put the code to set the checkbox to true then. As far as I know, the action class isn't called before after the form bean has called the reset method and the page has been rendered (and the submit button has been pressed), or is it something I am missing? BTJ On Tue, 2003-06-10 at 20:28, James Mitchell wrote: On Tuesday 10 June 2003 14:11, Bjørn T Johansen wrote: You are missing my point! If I just could set the checkbox value to false in the reset method, everything is fine. But there are times when that value has to be reset to true and not false and if I do that in my reset method, I am not able to see of the user unchek the checkbox, because the boolean variable is still true after the form has been posted! No, actually *YOU* are missing the point! Several people have tried to explain how this works to you. So, for one last effort IMPORTANT DO *NOT* SET THE FIELDS YOU INTENT TO USE AS CHECKBOXES (booleans) TO TRUE IN THE RESET METHOD! /IMPORTANT If you want the field to be true when the page is rendered, set it to true from your action class, NOT in the reset of your formbean. I hope that clears it up for you. BTJ On Tue, 2003-06-10 at 19:22, Tor Henrik Hanken wrote: [EMAIL PROTECTED] | Yes, but to clarify... | I am showing a jsp page with values read from a database. If the | checkbox value is true, how do I then make the checkbox on my jsp-page | checked and how do I then find out if the checkbox has been unchecked? | Do I have to manually read the posted data and see if the checkbox | attribute is missing or is there a better way? I assume that you are using an Action with an ActionForm. To make the value of the checkbox come up correctly, import struts tags into your jsp-page: %@ taglib uri=/WEB-INF/struts-bean.tld prefix=strb % %@ taglib uri=/WEB-INF/struts-html.tld prefix=strh % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=strl % Then use the Struts checkbox tag: strh:checkbox property=done/ Assuming that your form has the methods getDone and setDone, these methods will be used to render the value of the checkbox correctly. As to the question of boolean values that are set to false by the user: You don't have to parse the posted data manually. The method reset() in ActionForm is run before the posted data is used to populate the form. Write your own reset() method where you set the boolean fields to false. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox problem?
public ... execute (..., , ) { BeanUtils.setProperty(actionForm, checkboxPropertyName, true ) } or something similar, I believe. -Josh -Original Message- From: Bjørn T Johansen [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 3:38 PM To: Struts Users Mailing List Subject: Re: Checkbox problem? oki, maybe my explanation isn't the best :) (I know that I can't do it in the reset method, as it is clearly not working) but I am still not sure where to put the code to set the checkbox to true then. As far as I know, the action class isn't called before after the form bean has called the reset method and the page has been rendered (and the submit button has been pressed), or is it something I am missing? BTJ On Tue, 2003-06-10 at 20:28, James Mitchell wrote: On Tuesday 10 June 2003 14:11, Bjørn T Johansen wrote: You are missing my point! If I just could set the checkbox value to false in the reset method, everything is fine. But there are times when that value has to be reset to true and not false and if I do that in my reset method, I am not able to see of the user unchek the checkbox, because the boolean variable is still true after the form has been posted! No, actually *YOU* are missing the point! Several people have tried to explain how this works to you. So, for one last effort IMPORTANT DO *NOT* SET THE FIELDS YOU INTENT TO USE AS CHECKBOXES (booleans) TO TRUE IN THE RESET METHOD! /IMPORTANT If you want the field to be true when the page is rendered, set it to true from your action class, NOT in the reset of your formbean. I hope that clears it up for you. BTJ On Tue, 2003-06-10 at 19:22, Tor Henrik Hanken wrote: [EMAIL PROTECTED] | Yes, but to clarify... | I am showing a jsp page with values read from a database. If the | checkbox value is true, how do I then make the checkbox on my jsp-page | checked and how do I then find out if the checkbox has been unchecked? | Do I have to manually read the posted data and see if the checkbox | attribute is missing or is there a better way? I assume that you are using an Action with an ActionForm. To make the value of the checkbox come up correctly, import struts tags into your jsp-page: %@ taglib uri=/WEB-INF/struts-bean.tld prefix=strb % %@ taglib uri=/WEB-INF/struts-html.tld prefix=strh % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=strl % Then use the Struts checkbox tag: strh:checkbox property=done/ Assuming that your form has the methods getDone and setDone, these methods will be used to render the value of the checkbox correctly. As to the question of boolean values that are set to false by the user: You don't have to parse the posted data manually. The method reset() in ActionForm is run before the posted data is used to populate the form. Write your own reset() method where you set the boolean fields to false. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkbox problem?
You can pre-populate the form in a previous action. Here is an example. http://jakarta.apache.org/struts/faqs/newbie.html#prepopulate -Kevin --- Bjørn T Johansen [EMAIL PROTECTED] wrote: oki, maybe my explanation isn't the best :) (I know that I can't do it in the reset method, as it is clearly not working) but I am still not sure where to put the code to set the checkbox to true then. As far as I know, the action class isn't called before after the form bean has called the reset method and the page has been rendered (and the submit button has been pressed), or is it something I am missing? BTJ On Tue, 2003-06-10 at 20:28, James Mitchell wrote: On Tuesday 10 June 2003 14:11, Bjørn T Johansen wrote: You are missing my point! If I just could set the checkbox value to false in the reset method, everything is fine. But there are times when that value has to be reset to true and not false and if I do that in my reset method, I am not able to see of the user unchek the checkbox, because the boolean variable is still true after the form has been posted! No, actually *YOU* are missing the point! Several people have tried to explain how this works to you. So, for one last effort IMPORTANT DO *NOT* SET THE FIELDS YOU INTENT TO USE AS CHECKBOXES (booleans) TO TRUE IN THE RESET METHOD! /IMPORTANT If you want the field to be true when the page is rendered, set it to true from your action class, NOT in the reset of your formbean. I hope that clears it up for you. BTJ On Tue, 2003-06-10 at 19:22, Tor Henrik Hanken wrote: [EMAIL PROTECTED] | Yes, but to clarify... | I am showing a jsp page with values read from a database. If the | checkbox value is true, how do I then make the checkbox on my jsp-page | checked and how do I then find out if the checkbox has been unchecked? | Do I have to manually read the posted data and see if the checkbox | attribute is missing or is there a better way? I assume that you are using an Action with an ActionForm. To make the value of the checkbox come up correctly, import struts tags into your jsp-page: %@ taglib uri=/WEB-INF/struts-bean.tld prefix=strb % %@ taglib uri=/WEB-INF/struts-html.tld prefix=strh % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=strl % Then use the Struts checkbox tag: strh:checkbox property=done/ Assuming that your form has the methods getDone and setDone, these methods will be used to render the value of the checkbox correctly. As to the question of boolean values that are set to false by the user: You don't have to parse the posted data manually. The method reset() in ActionForm is run before the posted data is used to populate the form. Write your own reset() method where you set the boolean fields to false. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox problem?
Generally, a good strategy is to have a prepare action and a process action. Your prepare action is where you would set your boolean form properties. You then forward to the JSP, which renders the checkboxes. The process action (from submitting the form) will determine whether the checkboxes are set or not. -Original Message- From: Bjørn T Johansen [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 12:38 PM To: Struts Users Mailing List Subject: Re: Checkbox problem? oki, maybe my explanation isn't the best :) (I know that I can't do it in the reset method, as it is clearly not working) but I am still not sure where to put the code to set the checkbox to true then. As far as I know, the action class isn't called before after the form bean has called the reset method and the page has been rendered (and the submit button has been pressed), or is it something I am missing? BTJ On Tue, 2003-06-10 at 20:28, James Mitchell wrote: On Tuesday 10 June 2003 14:11, Bjørn T Johansen wrote: You are missing my point! If I just could set the checkbox value to false in the reset method, everything is fine. But there are times when that value has to be reset to true and not false and if I do that in my reset method, I am not able to see of the user unchek the checkbox, because the boolean variable is still true after the form has been posted! No, actually *YOU* are missing the point! Several people have tried to explain how this works to you. So, for one last effort IMPORTANT DO *NOT* SET THE FIELDS YOU INTENT TO USE AS CHECKBOXES (booleans) TO TRUE IN THE RESET METHOD! /IMPORTANT If you want the field to be true when the page is rendered, set it to true from your action class, NOT in the reset of your formbean. I hope that clears it up for you. BTJ On Tue, 2003-06-10 at 19:22, Tor Henrik Hanken wrote: [EMAIL PROTECTED] | Yes, but to clarify... | I am showing a jsp page with values read from a database. If the | checkbox value is true, how do I then make the checkbox on my jsp- page | checked and how do I then find out if the checkbox has been unchecked? | Do I have to manually read the posted data and see if the checkbox | attribute is missing or is there a better way? I assume that you are using an Action with an ActionForm. To make the value of the checkbox come up correctly, import struts tags into your jsp-page: %@ taglib uri=/WEB-INF/struts-bean.tld prefix=strb % %@ taglib uri=/WEB-INF/struts-html.tld prefix=strh % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=strl % Then use the Struts checkbox tag: strh:checkbox property=done/ Assuming that your form has the methods getDone and setDone, these methods will be used to render the value of the checkbox correctly. As to the question of boolean values that are set to false by the user: You don't have to parse the posted data manually. The method reset() in ActionForm is run before the posted data is used to populate the form. Write your own reset() method where you set the boolean fields to false. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox problem?
The suggested method requires two actions. SetupAction - Form - ProcessAction The first action prepares any values required by your form, including setting the value of your checkboxes to true. The second action is the one that actually processes the user input gathered by the form. Hope this clarifies things. Steve -Original Message- From: Bjørn T Johansen [mailto:[EMAIL PROTECTED] Sent: June 10, 2003 12:38 PM To: Struts Users Mailing List Subject: Re: Checkbox problem? oki, maybe my explanation isn't the best :) (I know that I can't do it in the reset method, as it is clearly not working) but I am still not sure where to put the code to set the checkbox to true then. As far as I know, the action class isn't called before after the form bean has called the reset method and the page has been rendered (and the submit button has been pressed), or is it something I am missing? BTJ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox problem?
Steve wrote: The suggested method requires two actions. SetupAction - Form - ProcessAction The first action prepares any values required by your form, including setting the value of your checkboxes to true. The second action is the one that actually processes the user input gathered by the form. Not necessarily two Actions... I use LookupDispatchAction with a request parameter to control which method should be called. -- Wendy Smoak
checkbox problem
Hello Struts user! I use a html:checkbox for setting a boolean value. But after submit, the boolean value in the form bean isn't set correctly. Do I have to use a String value for that in my form bean? I tried this, but without success. Regards, Bernhard -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: checkbox problem
may u need to reset the value of the checkbox to (false or true) in the reset method of ur formbean -Original Message- From: Hirschmann, Bernhard [mailto:Bernhard.Hirschmann;t-systems.com] Sent: Monday, November 11, 2002 7:00 PM To: '[EMAIL PROTECTED]' Subject: checkbox problem Hello Struts user! I use a html:checkbox for setting a boolean value. But after submit, the boolean value in the form bean isn't set correctly. Do I have to use a String value for that in my form bean? I tried this, but without success. Regards, Bernhard -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorised to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: checkbox problem
You need to set it to false in the reset() method. James Mitchell Software Engineer/Struts Evangelist http://www.open-tools.org If you were plowing a field, which would you rather use? Two strong oxen or 1024 chickens? - Seymour Cray (1925-1996), father of supercomputing -Original Message- From: Saini, Deepank [mailto:deepank.saini;cgey.com] Sent: Monday, November 11, 2002 8:33 AM To: 'Struts Users Mailing List' Subject: RE: checkbox problem may u need to reset the value of the checkbox to (false or true) in the reset method of ur formbean -Original Message- From: Hirschmann, Bernhard [mailto:Bernhard.Hirschmann;t-systems.com] Sent: Monday, November 11, 2002 7:00 PM To: '[EMAIL PROTECTED]' Subject: checkbox problem Hello Struts user! I use a html:checkbox for setting a boolean value. But after submit, the boolean value in the form bean isn't set correctly. Do I have to use a String value for that in my form bean? I tried this, but without success. Regards, Bernhard -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorised to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: checkbox problem
if u want uncheck the box, after a submit , set it to false -Original Message- From: James Mitchell [mailto:jmitchtx;telocity.com] Sent: Monday, November 11, 2002 7:06 PM To: Struts Users Mailing List Subject: RE: checkbox problem You need to set it to false in the reset() method. James Mitchell Software Engineer/Struts Evangelist http://www.open-tools.org If you were plowing a field, which would you rather use? Two strong oxen or 1024 chickens? - Seymour Cray (1925-1996), father of supercomputing -Original Message- From: Saini, Deepank [mailto:deepank.saini;cgey.com] Sent: Monday, November 11, 2002 8:33 AM To: 'Struts Users Mailing List' Subject: RE: checkbox problem may u need to reset the value of the checkbox to (false or true) in the reset method of ur formbean -Original Message- From: Hirschmann, Bernhard [mailto:Bernhard.Hirschmann;t-systems.com] Sent: Monday, November 11, 2002 7:00 PM To: '[EMAIL PROTECTED]' Subject: checkbox problem Hello Struts user! I use a html:checkbox for setting a boolean value. But after submit, the boolean value in the form bean isn't set correctly. Do I have to use a String value for that in my form bean? I tried this, but without success. Regards, Bernhard -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorised to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorised to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
AW: checkbox problem
Thanks for your comment, but I'm not sure if that's the problem. Here is the scenario: 1.) While populating the form, the value is true. 2.) Then the user disables the checkbox - for setting the value to false. 3.) Submit occurs. 4.) In the action I check the value and I see that it is true. Do I really have to reset the form for such a scenario? Regards, Bernhard -Ursprüngliche Nachricht- Von: James Mitchell [mailto:jmitchtx;telocity.com] Gesendet: Montag, 11. November 2002 14:36 An: Struts Users Mailing List Betreff: RE: checkbox problem You need to set it to false in the reset() method. James Mitchell Software Engineer/Struts Evangelist http://www.open-tools.org If you were plowing a field, which would you rather use? Two strong oxen or 1024 chickens? - Seymour Cray (1925-1996), father of supercomputing -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: checkbox problem
well i am not sure why it should show true if it has been unchecked, but one last shot, if u r calling a javascript function on the submit, the problem could well be in the javascript function. Bye the way do u have a submit button or r u caling a javascript function onchange of the checkbox? -Original Message- From: Hirschmann, Bernhard [mailto:Bernhard.Hirschmann;t-systems.com] Sent: Monday, November 11, 2002 7:12 PM To: 'Struts Users Mailing List' Subject: AW: checkbox problem Thanks for your comment, but I'm not sure if that's the problem. Here is the scenario: 1.) While populating the form, the value is true. 2.) Then the user disables the checkbox - for setting the value to false. 3.) Submit occurs. 4.) In the action I check the value and I see that it is true. Do I really have to reset the form for such a scenario? Regards, Bernhard -Ursprüngliche Nachricht- Von: James Mitchell [mailto:jmitchtx;telocity.com] Gesendet: Montag, 11. November 2002 14:36 An: Struts Users Mailing List Betreff: RE: checkbox problem You need to set it to false in the reset() method. James Mitchell Software Engineer/Struts Evangelist http://www.open-tools.org If you were plowing a field, which would you rather use? Two strong oxen or 1024 chickens? - Seymour Cray (1925-1996), father of supercomputing -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorised to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
AW: checkbox problem
Hi Deepank, I don't use a JavaScript function for this. I use a simple submit button. You missunderstood. It shouldn't be unchecked, if it is true. I didn't write that. But it may sounds a bit confusing what I've written: 4.) In the action I check the value and I see that it is true means: 4.) In the action I INSPECT the value and I see that it is true ;-) -Ursprüngliche Nachricht- Von: Saini, Deepank [mailto:deepank.saini;cgey.com] Gesendet: Montag, 11. November 2002 14:46 An: 'Struts Users Mailing List' Betreff: RE: checkbox problem well i am not sure why it should show true if it has been unchecked, but one last shot, if u r calling a javascript function on the submit, the problem could well be in the javascript function. Bye the way do u have a submit button or r u caling a javascript function onchange of the checkbox? -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: AW: checkbox problem
2002. november 11. 14:42 dátummal Hirschmann, Bernhard ezt írtad: Thanks for your comment, but I'm not sure if that's the problem. Here is the scenario: 1.) While populating the form, the value is true. 2.) Then the user disables the checkbox - for setting the value to false. 3.) Submit occurs. 4.) In the action I check the value and I see that it is true. Do I really have to reset the form for such a scenario? You store your ActionForm in the session I guess. The form has the property set true. On submit the form does not receive any value for the very property as there is no such request parameter since the cb was not checked. So the property stays unchanged (ie checked). What would uncheck it then? Maybe the reset(). Hth Tib -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
AW: AW: checkbox problem
Hey Tib, if I get you right, then the boolean value in the form will NOT be set to false, if I uncheck the cb and hit submit? Is that right? -Ursprüngliche Nachricht- Von: Gemes Tibor [mailto:gemes;regens.hu] Gesendet: Montag, 11. November 2002 14:58 An: Struts Users Mailing List Betreff: Re: AW: checkbox problem 2002. november 11. 14:42 dátummal Hirschmann, Bernhard ezt írtad: Thanks for your comment, but I'm not sure if that's the problem. Here is the scenario: 1.) While populating the form, the value is true. 2.) Then the user disables the checkbox - for setting the value to false. 3.) Submit occurs. 4.) In the action I check the value and I see that it is true. Do I really have to reset the form for such a scenario? You store your ActionForm in the session I guess. The form has the property set true. On submit the form does not receive any value for the very property as there is no such request parameter since the cb was not checked. So the property stays unchanged (ie checked). What would uncheck it then? Maybe the reset(). Hth Tib -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
/ /OREF:CPTD2D27 RE: checkbox problem
This posting is useful for dealing with checkboxes: http://www.mail-archive.com/struts-user;jakarta.apache.org/msg37244.html Saini, Deepank deepank.saini@c To: 'Struts Users Mailing List' [EMAIL PROTECTED] gey.com cc: Subject: RE: checkbox problem 11/11/2002 03:46 PM Please respond to Struts Users Mailing List well i am not sure why it should show true if it has been unchecked, but one last shot, if u r calling a javascript function on the submit, the problem could well be in the javascript function. Bye the way do u have a submit button or r u caling a javascript function onchange of the checkbox? -Original Message- From: Hirschmann, Bernhard [mailto:Bernhard.Hirschmann;t-systems.com] Sent: Monday, November 11, 2002 7:12 PM To: 'Struts Users Mailing List' Subject: AW: checkbox problem Thanks for your comment, but I'm not sure if that's the problem. Here is the scenario: 1.) While populating the form, the value is true. 2.) Then the user disables the checkbox - for setting the value to false. 3.) Submit occurs. 4.) In the action I check the value and I see that it is true. Do I really have to reset the form for such a scenario? Regards, Bernhard -Ursprüngliche Nachricht- Von: James Mitchell [mailto:jmitchtx;telocity.com] Gesendet: Montag, 11. November 2002 14:36 An: Struts Users Mailing List Betreff: RE: checkbox problem You need to set it to false in the reset() method. James Mitchell Software Engineer/Struts Evangelist http://www.open-tools.org If you were plowing a field, which would you rather use? Two strong oxen or 1024 chickens? - Seymour Cray (1925-1996), father of supercomputing -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorised to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: AW: AW: checkbox problem
2002. november 11. 15:01 dátummal Hirschmann, Bernhard ezt írtad: Hey Tib, if I get you right, then the boolean value in the form will NOT be set to false, if I uncheck the cb and hit submit? Is that right? Yes. The cb sends the parameter iff it is checked. If the form is stored in the session AND the form reset() does not set the property to false, the property will stay true for ever. Tib -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
AW: AW: AW: checkbox problem
Ok, I think I got it now... Thank you for your patience! ;-) One final question: do I have to call form.reset() manually, or is this done automatically? Regards, Bernhard -Ursprüngliche Nachricht- Von: Gemes Tibor [mailto:gemes;regens.hu] Gesendet: Montag, 11. November 2002 15:10 An: Struts Users Mailing List Betreff: Re: AW: AW: checkbox problem 2002. november 11. 15:01 dátummal Hirschmann, Bernhard ezt írtad: Hey Tib, if I get you right, then the boolean value in the form will NOT be set to false, if I uncheck the cb and hit submit? Is that right? Yes. The cb sends the parameter iff it is checked. If the form is stored in the session AND the form reset() does not set the property to false, the property will stay true for ever. Tib -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: AW: AW: AW: checkbox problem
2002. november 11. 15:14 dátummal Hirschmann, Bernhard ezt írtad: One final question: do I have to call form.reset() manually, or is this done automatically? give it a try ;-) Tib yes it is called automagically -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: AW: checkbox problem
On Mon, 11 Nov 2002, Hirschmann, Bernhard wrote: Date: Mon, 11 Nov 2002 14:42:05 +0100 From: Hirschmann, Bernhard [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Subject: AW: checkbox problem Thanks for your comment, but I'm not sure if that's the problem. Here is the scenario: 1.) While populating the form, the value is true. 2.) Then the user disables the checkbox - for setting the value to false. 3.) Submit occurs. 4.) In the action I check the value and I see that it is true. Do I really have to reset the form for such a scenario? Yes. Absolutely. The underlying problem is that an HTML submit includes *nothing* for an unchecked checkbox, so the server-side Struts code that populates your form bean's properties has no way to know that it should set this variable (there is no requirement that every form bean property exist in every submit, so you can't just use reflection to figure out which properties are valid). The Struts solution to this issue *requires* you to set boolean form bean properties to false in the reset() method in order to correctly deal with checkboxes. See the Struts user guide, and the documentation for the html:checkbox tag, for more details. Regards, Bernhard Craig -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Checkbox problem
In my form bean I have an attribute which is an Arraylist of objects who in turn contain many attributes one of which is a string representing a checkbox of my screen. Problem : -When I check anyof the check boxes and proceed to the next screens and comeback again to the screen having the check boxes to uncheck some of the checkboxes which I have checked earlier then it's not getting updated in the form bean. I have taken the default value of the attribute representing the checkbox as false. And when it gets checked I'm making it to True. So any solution? Thanks Kishor -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: Checkbox problem
I suppose you have several checkboxes corresponding to the List of objects. Are you using the html:multibox tag? If not, you should. The Struts framework will save the selected values in a String array that you provide. The value stored will be the value of the checkbox. For example html:multibox property=selectedItems value=foo/ if the checkbox is selected the array will include the string 'foo'. Have you looked at the html-multibox.jsp that is part of the struts-exercise-taglib application that ships with Struts? Sri -Original Message- From: Kishore, Sahu [mailto:kishores;tanning.com] Sent: Thursday, October 24, 2002 3:19 AM To: '[EMAIL PROTECTED]' Subject: Checkbox problem In my form bean I have an attribute which is an Arraylist of objects who in turn contain many attributes one of which is a string representing a checkbox of my screen. Problem : -When I check anyof the check boxes and proceed to the next screens and comeback again to the screen having the check boxes to uncheck some of the checkboxes which I have checked earlier then it's not getting updated in the form bean. I have taken the default value of the attribute representing the checkbox as false. And when it gets checked I'm making it to True. So any solution? Thanks Kishor -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: multibox, checkbox PROBLEM FOUND, SOLUTION NOT!!!
Ok suppose to have a Form with a checkbox named isOn and a submit button name Save a NOT checked value will produce: http://localhost:8080/webappointments/openChk.do?action=Save a checked value will produce: http://localhost:8080/webappointments/openChk.do?isOn=onaction=Save The problem is that if I have a checked value that I want to turn off I'll send http://localhost:8080/webappointments/openChk.do?action=Save the form function public void setIsOn( boolean isOn ) { this.isOn = isOn; } is not called and the value will not be changed. Where am I wrong ?? kiuma wrote: Hello agaaain, My checkboxes both multi and normal don't suppo all empty values. I.e. I can transmit a checked empty value, but I can't all empty values: I REALLY don't know what to do ... leease! --useredit_center.jsp-- %taglib uri=/WEB-INF/struts-bean.tld prefix=bean % %taglib uri=/WEB-INF/struts-html.tld prefix=html % %taglib uri=/WEB-INF/struts-logic.tld prefix=logic % %taglib uri=/WEB-INF/c.tld prefix=c % c:set var='jspPrincipalId' value='${sessionScope.userEditForm.principalId}'/ c:set var=jspAllGroups value=${sessionScope.userEditForm.allGroups}/ html:form action=/userPostChanges table class='edit' cellpadding=0 cellspacing='0' tbody tr c:if test=${jspPrincipalId != null} tdbean:message key=label.login//td td c:out value=${jspPrincipalId}/ html:hidden property=principalId/ /td /c:if c:if test=${jspPrincipalId == null} tdbean:message key=label.login//td td width='100%' html:text property=principalId size=50 maxlength=255/ /td /c:if /tr tr tdbean:message key=label.passwd1//td td width='100%' html:password property=passwd1 size=50 maxlength=255/ /td /tr tr tdbean:message key=label.passwd2//td td width='100%' html:password property=passwd2 size=50 maxlength=255/ /td /tr tr tdbean:message key=label.surname//td td width='100%' html:text property=name1 size=50 maxlength=255/ /td /tr tr tdbean:message key=label.name//td td width='100%' html:text property=name2 size=50 maxlength=255/ /td /tr tr tdbean:message key=label.cf//td td width='100%' html:text property=cf size=50 maxlength=16/ /td /tr tr tdbean:message key=label.piva//td td width='100%' html:text property=piva size=50 maxlength=13/ /td /tr tr tdbean:message key=label.address//td td width='100%' html:text property=address size=50 maxlength=255/ /td /tr tr tdbean:message key=label.zip//td td width='100%' html:text property=zip size=50 maxlength=10/ /td /tr tr tdbean:message key=label.city//td td width='100%' html:text property=city size=50 maxlength=255/ /td /tr tr tdbean:message key=label.state//td td width='100%' html:text property=state size=50 maxlength=255/ /td /tr tr tdbean:message key=label.country//td td width='100%' html:text property=country size=50 maxlength=255/ /td /tr tr tdbean:message key=label.phone//td td width='100%'
RE: multibox, checkbox PROBLEM FOUND, SOLUTION NOT!!!
I'm coming into this discussion late, so ignore me if I'm out in left field, but it sounds like you're unhappy that when *no* checkboxes are checked, *no* methods get called. When you submit the form, only successful form elements are sent in the request, so if *no* checkboxes are checked, *nothing* related to those checkboxes will be present in the request. Isn't this what the reset method is all about? The reset method will be called before Struts automagically populates all of your ActionForm fields. I can't tell what your Collection is from this post, but try clearing out *all* of the values in the Collection that handles your checkboxes in the reset() method of the Form. Then, if you uncheck all of the boxes and submit, you should see that none of them are checked when the form is redisplayed (or you use the data). Hope that helps, -- Wendy Smoak Arizona State University PA IRM
Re: multibox, checkbox PROBLEM FOUND, SOLUTION NOT!!!
Thanks a lot , you have been very clarifying. I've found a tip placing code in validate method : public ActionErrors validate( ActionMapping mapping, HttpServletRequest req) { String str = req.getParameter( isOn ); if (str == null) isOn = false; return null; } But it's a very dirty technique of course. Wendy Smoak wrote: I'm coming into this discussion late, so ignore me if I'm out in left field, but it sounds like you're unhappy that when *no* checkboxes are checked, *no* methods get called. When you submit the form, only successful form elements are sent in the request, so if *no* checkboxes are checked, *nothing* related to those checkboxes will be present in the request. Isn't this what the reset method is all about? The reset method will be called before Struts automagically populates all of your ActionForm fields. I can't tell what your Collection is from this post, but try clearing out *all* of the values in the Collection that handles your checkboxes in the reset() method of the Form. Then, if you uncheck all of the boxes and submit, you should see that none of them are checked when the form is redisplayed (or you use the data). Hope that helps, -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: multibox, checkbox PROBLEM FOUND, SOLUTION NOT!!!
Kiuma wrote: I've found a tip placing code in validate method : But it's a very dirty technique of course. That will work, but... what if you have a form that you don't want to validate? The reason this is working is that you have validate set to true so that the validate method gets called. If you set validate to false, it'll stop working. One line in your reset method will do the same thing: isOn = false; The reset method will autmatically get called before the set-methods for the successful form elements. So if the checkbox isn't checked, the isOn property will remain false. If it is checked, then the setIsOn method will be called and isOn will be set to true. For the sake of the person who has to maintain your code later on, (not to mention your own sanity when you look at this in six months,) use the validate and reset methods for their intended purposes. :) -- Wendy Smoak Arizona State University IA IRM
CheckBox problem in struts..
Hi Could anyone explain about the checkbox problem in struts if i have a checkbox in a jsp and if i set the value of the bean to yes, true or on, the checkbox will be checked. But if i try to set the value of the checkbox in the bean it is not getting set. if i submit data from checkbox it is not getting reflected when i revisit the page. Thanks Regards Sachin -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: CheckBox problem in struts..
reset the check box values in the struts form reset method. -Original Message- From: Sachin [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 6:35 PM To: [EMAIL PROTECTED] Subject: CheckBox problem in struts.. Hi Could anyone explain about the checkbox problem in struts if i have a checkbox in a jsp and if i set the value of the bean to yes, true or on, the checkbox will be checked. But if i try to set the value of the checkbox in the bean it is not getting set. if i submit data from checkbox it is not getting reflected when i revisit the page. Thanks Regards Sachin -- 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]
Checkbox problem still not fixed :(
Hi everyone. I've tried just about everything in the mail archive but can't get check/multi boxes to perform how I want to. I use an iterate tag over a collection, basically on my jsp page I have as follows form blah hidden name="pk" blah checkbox property="member" /form In my form bean I have an array pk[] and another member[]. In the reset method I do: for(int i = 0;imember.length;i++) member[i] = "false"; When I check the values off the form in my action class, i still only get the values set to true. I need a long list, true, false, true, true etc for all the values. Sorry to be a pain but can someone give me some sort of 'exact' steps to solve the problem? I haven't been able to piece together all the help on the mail archive. Thanks, Joel [EMAIL PROTECTED]
Re: Checkbox problem still not fixed :(
Hi! I had a similar problem and solved it by changing the attribute scope in my action in the struts-config.xml file to request instead of session. /Linnéa - Original Message - From: Joel Vogt To: [EMAIL PROTECTED] Sent: Thursday, June 28, 2001 10:04 AM Subject: Checkbox problem still not fixed :( Hi everyone. I've tried just about everything in the mail archive but can't get check/multi boxes to perform how I want to. I use an iterate tag over a collection, basically on my jsp page I have as follows form blah hidden name="pk" blah checkbox property="member" /form In my form bean I have an array pk[] and another member[]. In the reset method I do: for(int i = 0;imember.length;i++) member[i] = "false"; When I check the values off the form in my action class, i still only get the values set to true. I need a long list, true, false, true, true etc for all the values. Sorry to be a pain but can someone give me some sort of 'exact' steps to solve the problem? I haven't been able to piece together all the help on the mail archive. Thanks, Joel [EMAIL PROTECTED]
Re: Checkbox problem still not fixed :(
Hi all, I've worked on it a bit more and come up with these steps to make it work. I use a multibox instead of a checkbox like this on my form: html:multibox name="model" property="member" value="yes"/ I then also include with this a hidden field html:hidden name="model" property="member" value="no"/ The form bean remains the same. In my action class, I can then get the required values by looping like this int j = 0; for (int i = 0; imember.length;i++) { if (member[j].equals("yes")) { // This person is a member so do required events; j+=1; } else// this person is marked to not be a member j+=1; } This works because if the multibox was checked to true, there will be two values for each user, a true for the multibox and then the no from the hidden field. If the multibox is not checked then we only get one entry, a no from the hidden field. To me this is a bit ineligant. Sure it works, but... Any other solutions? Btw Thanks to all the people offering help on this, it seems struts has a good community going. Joel. - Original Message - From: Joel Vogt To: [EMAIL PROTECTED] Sent: Thursday, June 28, 2001 10:04 AM Subject: Checkbox problem still not fixed :( Hi everyone. I've tried just about everything in the mail archive but can't get check/multi boxes to perform how I want to. I use an iterate tag over a collection, basically on my jsp page I have as follows form blah hidden name="pk" blah checkbox property="member" /form In my form bean I have an array pk[] and another member[]. In the reset method I do: for(int i = 0;imember.length;i++) member[i] = "false"; When I check the values off the form in my action class, i still only get the values set to true. I need a long list, true, false, true, true etc for all the values. Sorry to be a pain but can someone give me some sort of 'exact' steps to solve the problem? I haven't been able to piece together all the help on the mail archive. Thanks, Joel [EMAIL PROTECTED]