• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Check Box Handling

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You Merrill Higginson

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