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.
Thanks and Regards
Omkar Patkar (SCJP 1.4)[url]http://javacollectionsnotes.blogspot.com[/url] | [url]http://omkar-myscjpexp.blogspot.com[/url]
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.
Joined: Aug 25, 2005
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 ?
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.