Hi,
I success you use a List and iterate over it. Like this:
In your Action:
private List<MyObject> myObjects; // with getter and setter !
use the prepare methode to create the objects
public void prepare() throws Exception {
myObjects = new ArrayList<MyObject>();
myObjects.add(new MyObject());
myObjects.add(new MyObject());
myObjects.add(new MyObject());
and in your jsp you iterate
<s:iterator value="#myObjects" status="stat">
(see http://struts.apache.org/2.x/docs/iterator.html )
</s:iterator>
Than you treat the input in your action something like this:
List<MyObject> result = new ArrayList<MyObject>();
for(MyObject o: objectList.getObjects() ) {
if(o != empty() )
result.add(o)
}
This ist not a working example just gives you the idea. As an example
you should look how appfuse handels user roles. Look into User,
UserAction and userForm.jsp.
kind regards
Allan DV. Daños schrieb:
Hi all,
Is there a way I can implement this one?
I know that array of fields is allowed:
<input type="text" name="num" value="1">
<input type="text" name="num" value="2">
And in the action I have:
int[] num; //and its setter
This one is also allowed:
<input type="text" name="myobj.name" value="obj1">
And in the action I have:
MyObj myobj; //and its setter
How about if I want multiple objects in my form?
Something like :
<input type="text" name="myobj.name" value="obj1">
<input type="text" name="myobj.name" value="obj2">
And in the action I have:
MyObj[] myobj;
But this is not allowed!
FYI: Any work around? I have a lot of fields in myobj.
Please help!
Thanks in advanced! ^__^
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]