Ahhhh... (lightbulb moment)..... I thought you could only use array indexes
in the value attribute of s: tags.

So if I have a composite object which had fieldName and fieldValue I could
put;

CompositeObject[] getPairs()

in the action which uses the JSP to display the data and 

setPairs(CompositeObject[] pairs)

in the action which updates the database.

This is great, the only other thing is I've now got to put a mapping in
place because the original IDs are generated by Hibernate and will probably
be non-sequential and almost definatley non-zero based, but that's a non S2
story.

Many Many Many thanks.

Al.


-----Original Message-----
From: Dave Newton [mailto:[EMAIL PROTECTED] 
Sent: 16 May 2007 18:37
To: Struts Users Mailing List
Subject: RE: [Fwd: Best method for dynamic fields round trip]

Just off of the top of my head I would probably use a collection or map of
name/values... so the tag might look something like:

<s:textfield name="pairs[fieldId].fieldName"/> <s:textfield
name="pairs[fieldId].fieldValue"/>

etc. (with minor syntax changes depending on how things are shuffled to the
JSP).

d.

--- Al Sutton <[EMAIL PROTECTED]> wrote:

> The main part I'm having trouble with is keeping the association 
> between the editable field name and the editable value, so if we start 
> with
> 
> Phone1 : 555-12345
> 
> And the user changes the field name and value to be
> 
> Fax : 555-12346
> 
> Getting the action to recognise that it should update the both values.
> 
> This is part of porting an app to s2, and currently it's don using two 
> input fields which include an id, so it's basically
> 
> <input type="text" name="fieldname_<%=fieldId%>"
> value="phone1">
> <input type="text" name="fieldvalue_<%=fieldId%>"
> value="555-12345">
> 
> Currently the servlet taking the input goes through the servlet 
> request parameter map and when it finds a request parameter that 
> starts with fieldname_ it gets the corresponding fieldvalue_ entry and 
> updates the field record with the id.
> 
> If there is a nice way I'd appreciate a pointer because at the moment 
> it looks like we're going to have to use the same method of going 
> through the parameter map which feels like it's a bit of a hack and 
> makes unit testing a bit more tricky.
> 
> Al.
> 
> 
> -----Original Message-----
> From: Dave Newton [mailto:[EMAIL PROTECTED]
> Sent: 16 May 2007 18:19
> To: Struts Users Mailing List
> Subject: RE: [Fwd: Best method for dynamic fields round trip]
> 
> --- Al Sutton <[EMAIL PROTECTED]> wrote:
> > That's just what I was looking for, thanks Dave. I
> was looking for a
> > way to do it with <s:xxx/> tags,
> so
> > I'm now more confident it's best done without them
> as opposed to
> > thinking I might have missed something.
> 
> Well, I'm just one opinion :)
> 
> It could still be done with the S2 tags if, say, you had a map of 
> dynamic parameter names (or ids, etc.) and iterate over the map etc.
> 
> It may depend more on how the dynamic parameters are defined or 
> declared, etc. I think either way is acceptable, though (the map idea 
> might be easier in some ways)... it just depends.
> 
> d.
> 
> 
> 
>        
>
____________________________________________________________________________
> ________You snooze, you lose. Get messages ASAP with AutoCheck in the 
> all-new Yahoo! Mail Beta.
>
http://advision.webevents.yahoo.com/mailbeta/newmail_html.html
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 



       
____________________________________________________________________________
________Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see
what's on, when. 
http://tv.yahoo.com/collections/222

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to