struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Turner" <stur...@MIT.EDU>
Subject Re: How to handle input from iterated output
Date Mon, 01 Feb 2010 16:38:05 GMT
On Mon, 01 Feb 2010 10:55:55 -0500, Craig Ricciuto  
<cricciuto@symboticware.com> wrote:

> Hi, just a quick question.
> I have a class that has 4 fields. 2 Strings, 1 int, 1 boolean.  I shall
> refer to this class as MyClass
> In my Action class I have a List (call it MyList) that is a list of  
> MyClass.
> It can be populated with as little as 1 item or as many as say 256 items
> (could be more but I'll keep this limit for simplicity).
> Iterating through MyList in a JSP with the struts tag
> <s:iterator........</s:iterator> is easy enough. My question is this....
>
> When I iterate through MyList in the JSP I'm setting form fields (of all  
> 4
> fields from MyClass).  What would be the best way to get all that input  
> back
> when I submit the form?
> Is there an example of this somewhere I haven't found or just a pretty
> straightforward way of doing this I'm not thinking of?
>
> Thanks,
> Craig

You just need to tell struts what type of objects are in the list:

http://struts.apache.org/2.0.8/docs/type-conversion.html

Basically this would involve a "Myaction-conversion.properties" file  
alongside the action class. It would contain:

Element_MyList=mypackage.MyClass

Also, there's a pretty good section on this in "Struts in Action".

Steve

-- 
Stephen Turner
Senior Programmer/Analyst - SAIS
MIT IS&T

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


Mime
View raw message