• 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

Disabled checkbox problem.

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

I have got a different problem. I have a checkbox which,... depending upon certain condition it is either disabled or its not disabled. However according to the requirement i want to send the value of a boolean property in form bean associated with this checkbox. Currently, i get "false" value. But, that should not be the case. For e.g. If the checkbox is "CHECKED" and its disabled, then i must be able to send "true" to database. and if the checkbox is "NOT CHECKED", and its disabled then i must be able to send "false" to the database. In other words, its just for the user to know that the checkbox is a readonly field. However, if the checkbox is not disabled, then its usual, behavior must take place. How do i do that ? ...I am using struts 1.2.8. Merill any idea ?

Thanks and regards
Omkar Patkar.
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Disabled form elements are not submitted with the form. You'll probably have to use a hidden field to keep track of the checkbox's status.
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dom,
Thanks Man ! Ok then lets say, i have 4 fields in my form :-

1) First Name (textbox)
2) Second Name (textbox)
3) Mobile (textbox)
4) Is Admin ? (checkbox)


So my form fields will also contain four properties....right ? Now, if i keep a hidden field in the form (i.e., 5th field) then i will have to access the value of hidden field as if i was accessing the value of the check box. .... i hope i am correct ! But, that will be working perfectly well, if my checkbox is always disabled. In my application, the checkbox is conditionally disabled ...i.e., READONLY, depending upon rights of the logged in user. When the checkbox is not disabled, then it is made editable to user. So if user "CHECKs" the checkbox then "true" must be sent. On the other hand, when user unchecks the checkbox, then "false" must be sent to the database. ... Now how this can be achieved using that hidden field ?

Thanks and Regards
Omkar Patkar.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wrap your <html:hidden> tag inside a <logic:equal> tag based on the same condition that determines whether or not the checkbox is disabled. That way the hidden field will be rendered only if the checkbox is disabled. Otherwise, only the checkbox will be rendered, and it will function normally.
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merill and Dom, .... The hidden field method is working !
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic