You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Charlesworth, Chico" <Ch...@softwareag.co.uk> on 2002/02/11 12:31:03 UTC

Passing a collection (ArrayList or string array) to the Action cl ass from the jsp page ...

Hi,

 

I'm trying to find the best way in struts of passing a collection of new
values to an action class, but there doesn't seem to be an easy way of doing
this ...

 

Here's a given scenario:

got a form with an arraylist.

in the jsp do a <logic:iterate> within a <html:form> tag, and within the
iterate tag do a <html:hidden property="myArrayListElement" value="0"/>

when I then invoke the action class, I would expect that my arraylist would
then have multiple values of "0", but instead it's null.

 

Similar sort of thing happens with string arrays ... 

so am I correct in saying that struts populates single form elements (like
strings), but does not populate collections?

 

At the moment I have to have a hidden String element, which when I submit
the form, I have to manually populate this string with the collection
values, and comma separate them. This seems a lot of work to do something so
simple.

 

Does anyone know of an easier way round this?

 

Cheers - Chico.

 


-- 
The content of this e-mail is confidential, may contain privileged material
and is intended solely for the recipient(s) named above. If you receive this
in error, please notify Software AG immediately and delete this e-mail.

Software AG (UK) Limited
Registered in England & Wales 1310740
Registered Office: Hudson House, Hudson Way,
Pride Park, Derby DE24 8HS