James Carr wrote:
Hi All,

I want to be able to submit a form that can add array elements to one
of my action properties. I have something like this:

public class SomeAction{
     private FooBar foo;
     // getters and setters, execute, etc. here
}

with

public class FooBar{
    private List<Bar> bars;
    // getters and setters
}


how can I submit elements in a way that adds new elements to the list
in FooBar? I can set FooBar fine, but trip up on the array portion. I
need to know how to do this without using the s2 taglib, as I am
sending a json request.

Thanks,
James


Assuming valueA and valueB are properties of Bar:

/some.action?foo.bars[0].valueA=textA&foo.bars[0].valueB=textB&foo.bars[1].valueA=textC&foo.bars[1].valueB=textD

That reads set valueA of index 0 in the bars list of foo to "textA". It should be URL encoded.

Important:
The list needs to either be instantiated before the parameter interceptor sets values on it, or the list needs to be able to be instantiated by the framework. This is the point that causes most people to stumble and the feedback from the framework is poor. You'll save yourself some effort if the constructor of FooBar initialises bars so the framework sees a non-null concrete list implementation.



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

Reply via email to