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

Reply via email to