Try as below.

<s:iterator value="addresses" status="row">
        <s:textfield name="addresses[%{#row.index}].city" name="%{city}" />
        <s:textfield name="addresses[%{#row.index}].state" name="%{state}"
/>
</s:iterator>

Regards,
Raghuveer Vellanki

-----Original Message-----
From: Mittal, Nitin (US - Mumbai) [mailto:nimit...@deloitte.com] 
Sent: Wednesday, January 20, 2010 10:54 PM
To: Struts Users Mailing List
Subject: RE: How to convert request parameters into Collection type - Set

Ok, so I want to understand how that would work if Set contains elements of
a complex type,like Address as follows:

setAddresses(Set<Address> adresses)
Inthis case, Jsp should define text fields as follows:

addresses.city
addresses.state

adresses.city
addresses.state

How would struts arrange the fields above into a set of Address objects,
associating right combination of city and state for each Address

Nitin Mittal,
Deloitte Consulting India Pvt. Ltd
Tel: + 91 9819213942(mobile)
nimit...@deloitte.com

----- Original Message -----
From: Steven Yang <kenshin...@gmail.com>
Sent: 20 January 2010 6:49 PM
To: Struts Users Mailing List <user@struts.apache.org>
Subject: Re: How to convert request parameters into Collection type - Set


simply loose the "[n]" just have all fields with name "middleNames"

On Wed, Jan 20, 2010 at 8:34 PM, Mittal, Nitin (US - Mumbai) <
nimit...@deloitte.com> wrote:

> Hi,
> I need help in mapping JSP text fields to a setter in action class which
>  have parameter as Set<String>
>
> I know Struts 2 supports automatically converting sets of request
> parameters into properties of various Collection type Lists
> This can be done by having a setter in the action class as -
> setMiddleNames(ArrayList<String> middleNames)
> JSP code should contain text fields as follows:-
> <s:textfield name="middleNames[0]" label="middleNames"/>
> <s:textfield name="middleNames[1]" label="middleNames"/>
> <s:textfield name="middleNames[2]" label="middleNames"/>
>
> Question :- How to map JSP text Fields or Hidden fields to setters in
> Action class which have parameter as Set<String>
>
> For example, how should I define text fields in JSP so that they can be
> mapped to the following setter in Action Class:-
> setMiddleNames(Set<String>)
>
>
> Thanks,
> Nitin Mittal
> Deloitte Consulting India Private Limited
> cell:+91 9819213942 | office:+91 22 66445762 | VOIP:+1  615-718-8170 |
> Fax:+91 22 66445999
> nimit...@deloitte.com
>
> . Please consider the environment before printing.
>
>
>
> This message (including any attachments) contains confidential information
> intended for a specific individual and purpose, and is protected by law.
If
> you are not the intended recipient, you should delete this message.
>
> Any disclosure, copying, or distribution of this message, or the taking of
> any action based on it, is strictly prohibited. [v.E.1]
>
>



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

Reply via email to