Hi, Using checkbox in struts is become eating an elephant for me. First of all setting default value as checked is difficult. And now when I did this using formbean as set the value of checkbox true in the constructor of formbean, A new problem arise. Now if I unchecked the box manually and then submit the box the value it set to the db is true rather false.
All values controlled by a checkbox should be set to false in the reset() method of the form bean. If you need a particular checkbox to be shown as checked by default, set the value to true in the action class prior to forwarding to the JSP, not in the reset() method.
The problem here is that when a checkbox is unchecked, it does not send a value to the server when the form is submitted. Consequently, the setter on your ActionForm bean is not called. The only way around this quirk of HTML is to set all values controlled by checkboxes to false in the reset() method.