Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Struts: checkbox's previous value remains after unselecting it

843836Sep 1 2004 — edited Dec 13 2007
hi
I have a checkbox in a JSP in struts environment:
<html:checkbox property="conversionOption"/>
now in struts-config, the dynaactionform is :
<form-bean name="QuoteDetailsBean" type="org.apache.struts.validator.DynaValidatorActionForm">
                            ...................
                                  <form-property name="conversionOption" type="java.lang.String"/> 
                          ..........................
              </form-bean>
now if the checkbox is not clicked, and in the action class I do:
String s = (String)formbean.get("conversionOption");
s is null.
Now when i check(select) the check box, and click on submit the String s is 'on'. After this if I click on 'back' button and then uncheck the checkbox and click submit., the String is still 'on'. I expect it to be null or something other than 'on'.
It seems struts does not set conversionOption property if the checkbox for that property is not selected. so the previous value remains.
how do I overcome this?
I tried by changing :
<form-property name="conversionOption" type="java.lang.String"/>
to
<form-property name="conversionOption" type="java.lang.String[]"/>
but it did not help. changing to String[] will help if i have musltiple checkboxes for the same property. but my form has only one checkbox.
can anybody please help me?
Tanveer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2008
Added on Sep 1 2004
18 comments
1,740 views