You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shyam A <st...@yahoo.com> on 2003/11/18 18:00:37 UTC

Array of / not retaining state after validation

Hi,

I have a scenario where I have an array of checkboxes
along with other data displayed in a table format on a
JSP. I have to keep track of which checkbox is checked
or unchecked when a user submits the form. I use the
validate() method of my ActionForm to do validation.
However, the values of the checkboxes are not retained
when a validation error occurs.

I have tried the following in vain:

a. Array of <html:checkbox>
   I have used a boolean array for the form data type
corresponding to the checkbox. Also, I set all the
values of the boolean array to false in the reset()
method.

b. Array of <html:multibox>
    In this case, I have a String array for the form
data type, and the array is not populated initially.
The value of the <html:multibox> is obtained from a
bean stored in the session, i.e

<html:multibox property="formProperty"
value="<%=someValue%>">
</html:multibox>

which is inside a <logic:iterate> loop.

Also, in the reset method of the form, I set the value
of the String array to "null" (this has worked for me
in the past). I'm not sure how to set the array length
to 0. 

Unfortunately, both of the above approaches don't help
in retaining the states of the checkboxes when a
validation error occurs.

I also tried using Javascript to populate a hidden
variable with the values of the checkboxes on form
submission, and setting the checkbox array with the
hidden variable array when a validation error occurs.
This didn't work either.

Could somebody tell me what I'm doing wrong?

Any help/pointers will be greatly appreciated.

Thanks,
Shyam








__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org