hi
I have a couple of checkboxes in a
jsp page used in
struts framework. I am using DynaValidatorForm as form bean with session scope, so it means the properties are mapped only in the struts-config.xml. the checkboxes' property names are checkbox1 and checkbox2.
now the in the action class, i do:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception {DynaValidatorForm dynaform = (DynaValidatorForm)form; System.out.println("1st checkbox value:"+ dynaform.get("checkbox1") ); System.out.println("2nd checkbox value:"+ dynaform.get("checkbox2") ); .....}
Now if I check the first checkbox and press on submit button, the action class prints out:
1st checkbox value: on
2nd checkbox value: off
this is as expected
Now I click on the back button, then i uncheck the first checkbox and click on submit.
the output is same as before, i.e.:
1st checkbox value: on //wrong
2nd checkbox value: off
I expected it to be
1st checkbox value: off
2nd checkbox value: off
That means if in a session if i check on checkbox 'on', and i go back and uncheck it, the uncheck is never stored, i.e. the property is never set to 'off' .
Now if i check the second one, and click on submit, output is :
1st checkbox value: on //expected off
2nd checkbox value: on //correct
now i go back and uncheck the 2nd checkbox (the first checkbox is already unchecked before), click submit and i get this output:
1st checkbox value: on //expected off
2nd checkbox value: on //expected off
Please let me know what is happening. I expect the values of uncheck boxes to be 'off' when i go back and uncheck them.
thanks
Tanveer