Hi.  I'm having a little trouble posting an array of objects to an Action.  I have 
container class that contains a few Vectors of other container classes, like so:

        public class Harman
        {
                private Vector kardons;
                // Omit getters and setters for brevity.

                public Harman( )
                {
                        kardons = new Vector();
                }
        }

        public class Kardon
        {
                private String value;
                // Omit getters and setters for brevity.
        }

Then I created an Action class that contains a Harman object and I use 
BeanUtil.setProperties() to populate the fields of the object, like so:

        public class HarmanAction extends ActionSupport
        {
                private Harman harman;
                // Omit getters and setters for brevity.
                
                public HarmanAction( )
                {
                        harman = new Harman();
                }

                public String doExecute( ) throws Exception
                {
                        parameters = ActionContext.getSingleValueParameters();
                        BeanUtil.setProperties(parameters,harman);
                        return SUCCESS;
                }
        }

Now the problem is that I can't figure out how to populate the field value inside one 
of the Kardon objects in the kardons Vector.  The first thing I tried was having the 
name in my <ui:textfield/> set to index into the Vector, like so:

        ... some HTML with a form ...
        <ui:textfield name="'kardons[0]/value'" label="'unimportant'"/>
        ... some HTML with the form submit button, etc. ...

Now this spews the following when I try to submit the form:

        Could not set parameter "kardons[0]/value":java.lang.IllegalArgumentException: 
The target object for property 'kardons[0]/value'. The target object needs to be 
initialized to a non-null value in order to set this property.

I tried omitting the index because that seemed to work when I had an array of Strings. 
 However, in this case, the value was just ignored and didn't populate the field.  I 
also tried changing the Vector to an array and also a List.  Each time, I still got 
the same error.  So my question is, how can a post an array of objects?

Yoway Buorn
Software Engineer
Imagery Systems Engineering

GENERAL DYNAMICS
Advanced Information Systems

112 Lakeview Canyon Road
Thousand Oaks, CA 91362-5027
Tel 805 497 5074
Fax 805 497 5050
[EMAIL PROTECTED]

-=[ c o l l e c t i v e - b a s s - j u n e 2 0 ]=-



-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to