• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Check Box Handling

 
Syed Saifuddin
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Syed Saifuddin
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Merrill Higginson

You lead me to the solution. You are too good
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic