RE: wrong behavior of checkboxes in forms?
I'm having the same problem. Did you ever get this to work? Thanks, Bradley Reneer -Original Message- From: Hartmut Bernecker [mailto:[EMAIL PROTECTED]] Sent: Mon, August 13, 2001 5:17 AM To: [EMAIL PROTECTED] Subject: Re: wrong behavior of checkboxes in forms? Gregor Rayman schrieb: Hartmut Bernecker [EMAIL PROTECTED] wrote: Hello, I have a checkbox in a form. If I check it and then submit the form, then I receive the value true in the action when calling the method form.getMyCheckbox(); But if I uncheck the checkbox and submit the form again, then I receive **again** the value true in the action when calling the method form.getMyCheckbox(); Who can help??? Hartmut Hi, there are two possible solutions: 1) use request scope forms 2) implement the reset() method. (Which you should do anyway always, when you use checkboxes) -- gR I had implemented the reset() method: public void reset(ActionMapping mapping, ServletRequest request) { myCheckbox = false; [...] } But anyway: the problem persists.
RE: wrong behavior of checkboxes in forms?
You should check the parameters in the HttpServletRequest object, from what I gather, the request object is only populated with checkbox names that are checked/true, when the form is submitted (not checkboxes that are un-checked/false). Therefore you need to compare values of checkboxes in your FormBean to ensure they're correct w.r.t. the values in the request. So, you may have some checkboxes set to true in your bean (from previous activity), that have been un-checked in the current submission, you can tell if it has been un-checked by looking to see if the checkbox name is NOT in the current request. The reset method is called before the JSP loads (drags data from the FormBean), so you should do something like this: public void reset(ActionMapping mapping, HttpServletRequest request) { Enumeration params = request.getParameterNames(); // look at vals in params compare with checkbox vals in FormBean // i.e. set all checkbox names in request to true, and rest to false } Hope this helps - Greg -Original Message- From: Brad Reneer [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 19, 2001 10:10 AM To: [EMAIL PROTECTED] Subject: RE: wrong behavior of checkboxes in forms? I'm having the same problem. Did you ever get this to work? Thanks, Bradley Reneer -Original Message- From: Hartmut Bernecker [mailto:[EMAIL PROTECTED]] Sent: Mon, August 13, 2001 5:17 AM To: [EMAIL PROTECTED] Subject: Re: wrong behavior of checkboxes in forms? Gregor Rayman schrieb: Hartmut Bernecker [EMAIL PROTECTED] wrote: Hello, I have a checkbox in a form. If I check it and then submit the form, then I receive the value true in the action when calling the method form.getMyCheckbox(); But if I uncheck the checkbox and submit the form again, then I receive **again** the value true in the action when calling the method form.getMyCheckbox(); Who can help??? Hartmut Hi, there are two possible solutions: 1) use request scope forms 2) implement the reset() method. (Which you should do anyway always, when you use checkboxes) -- gR I had implemented the reset() method: public void reset(ActionMapping mapping, ServletRequest request) { myCheckbox = false; [...] } But anyway: the problem persists.
Re: wrong behavior of checkboxes in forms?
Hartmut Bernecker [EMAIL PROTECTED] wrote: Hello, I have a checkbox in a form. If I check it and then submit the form, then I receive the value true in the action when calling the method form.getMyCheckbox(); But if I uncheck the checkbox and submit the form again, then I receive **again** the value true in the action when calling the method form.getMyCheckbox(); Who can help??? Hartmut Hi, there are two possible solutions: 1) use request scope forms 2) implement the reset() method. (Which you should do anyway always, when you use checkboxes) -- gR
wrong behavior of checkboxes in forms?
Hello, I have a checkbox in a form. If I check it and then submit the form, then I receive the value true in the action when calling the method form.getMyCheckbox(); But if I uncheck the checkbox and submit the form again, then I receive **again** the value true in the action when calling the method form.getMyCheckbox(); Who can help??? Hartmut
Re: wrong behavior of checkboxes in forms?
Gregor Rayman schrieb: Hartmut Bernecker [EMAIL PROTECTED] wrote: Hello, I have a checkbox in a form. If I check it and then submit the form, then I receive the value true in the action when calling the method form.getMyCheckbox(); But if I uncheck the checkbox and submit the form again, then I receive **again** the value true in the action when calling the method form.getMyCheckbox(); Who can help??? Hartmut Hi, there are two possible solutions: 1) use request scope forms 2) implement the reset() method. (Which you should do anyway always, when you use checkboxes) -- gR I had implemented the reset() method: public void reset(ActionMapping mapping, ServletRequest request) { myCheckbox = false; [...] } But anyway: the problem persists.
Re: wrong behavior of checkboxes in forms?
Setting the checkbox to false should solve the problem. Double-check your code. Hartmut Bernecker wrote: I had implemented the reset() method: public void reset(ActionMapping mapping, ServletRequest request) { myCheckbox = false; [...] } But anyway: the problem persists.