struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Zendle" <joe.zen...@vericept.com>
Subject order of bean form population
Date Fri, 18 Jul 2003 16:22:34 GMT
This is probably a JSP question but here goes:

What is the order in which bean properties are populated. Is it from 1st
to last as defined in the class (assuming reflection is used)? Can I
reliably use a property's value defined 1st to make a decision of how to
populate a later attribute? I am trying to make a form that can be used
to hold various business entities that share common attributes. 

Ex:

Assume hidden value is used in jsp to populate dataType below:

class MyForm extends ActionForm {
       private String dataType;
       private Vector holdsBaseClass = new Vector();


       public Set/getDataType(){}

       BaseClass getHoldsBaseClass(int index) {
           // need to know the concrete type to add
           while (holdsBaseClass.size()-1 < index) {
                if ( dataType.equals("derived1")
                     holdsBaseClass.add(new Derived1());
                if ( dataType.equals("derived2")
                     holdsBaseClass.add(new Derived2());
           }
           return holdsBaseClass.elementAt(index);
        }
}

       

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message