aspose file tools*
The moose likes Struts and the fly likes Check Box Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Check Box Handling" Watch "Check Box Handling" New topic
Author

Check Box Handling

Syed Saifuddin
Ranch Hand

Joined: Sep 01, 2003
Posts: 130
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.

Any help in this regard is highly appreciateable.

Thank You
Syed Saifuddin


Thank You & Best Regards,

Syed Saifuddin,
Senior Software Engineer

SAP Oracle AIX & Java Training
http://www.socialinet.com
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Syed Saifuddin
Ranch Hand

Joined: Sep 01, 2003
Posts: 130
Thank You Merrill Higginson

You lead me to the solution. You are too good
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Check Box Handling