With s2, you can do tabular forms quite elegantly. Although the page
needs some updates (will try to get on this the next days), the basic
principle is shown here:
http://cwiki.apache.org/confluence/display/WW/Tabular+inputs
You might want to make sure you understand type conversion principles
beforehands, especially for collection types.
M Cody schrieb:
I'm new to struts 2 and I'm trying to setup an edit form that will have an
array of text boxes that will transfer their values back to the action for
processing.
I've tried a couple things, but I'm thinking I'm just approaching it all wrong
or missing some key link somewhere and I can't find an example for struts 2
that directly addresses what I'm trying to do. I'll psuedocode out what I've
tried, but if anyone has a an example that my google-fu is too weak to find, or
can give me a simple run down on the right approach that would be great.
ItemClass
String getProp1()
setProp1(String)
String getProp2()
setProp2(String)
Action class
execute
save
String getMessage()
setMessage(String)
ItemClass[] getItems ()
setItems (ItemClass[])
JSP
form (posts to save)
TextField - name=message
(I've tried this part two ways)
TextField - name=items[0].prop1
TextField - name=items[0].prop2
TextField - name=items[1].prop1
TextField - name=items[1].prop2
(Second try)
Iterator id=it value=items
TextField - name=it.prop1
TextField - name=it.prop2
I was able to get both methods to display the data correctly in all the text
fields, and the message value is being posted to the action correctly on
submit, but the items array is always null after submit no matter what I do.
I've done nothing special in the struts config files to desginate that this
property is an array. Could that be it?
Thanks
Mike
--
Rene Gielen | http://it-neering.net/
Aachen | PGP-ID: BECB785A
Germany | gielen at it-neering.net
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]