tags:

views:

226

answers:

2

can array be used as hidden variable on jsp.....like I have a form i.e a simple java class,I want it to be as hidden variable can I do it..

Thanks in advance

A: 

just write multiple hidden elements with the same name en different values. struts will see that it is supposed to be an array

Salandur
+2  A: 

HTTP request parameters can only be strings. So you either have to convert it to a single string (maybe a commaseparated string?), but you need to convert it back yourself, or you have to use multiple hidden input values (all with the same name), which is generally a much better solution. In plain JSP/Servlet you can get them back using HttpServletRequest#getParameterValues() and Struts is smart enough to see that.

<logic:iterate id="foo" name="bean" property="arrayOrList">  
    <html:hidden name="paramName" property="propertyName" indexed="true" />  
</logic:iterate>
BalusC