If I define a sub-class of DynaValidatorForm I just have to add
    two methods to access to the list parameter, isn't it ?

    public final class MyDynaForm extends DynaValidatorForm {

            private ArrayList list;

            public MyDynaForm () 
            {   
          list = new ArrayList();
                ConfProp props = new ConfProp();
          Vector v = props.getMeterHosts();
                for (int i=0; i<v.size(); i++)
              list.add(v.elementAt(i));
                setList(list);
            }

            public ArrayList getList() {
                return list;
            }

            public void setList(ArrayList list) {
                this.list = list;
            }
    }

    I will wish to be certain that it is the best way to display a
collection in DynaValidatorForm 
    because I have a doubt in a message of the archives I read: 
    The only reason you would ever need to create a real class that extends
    DynaActionForm or DynaValidatorForm would be if you need a custom
reset()
    or validate() method.       

    What do you think about it?  


----------------------------------------------------------------------------

As of February 12th, 2003 Thomson unifies its email addresses on a worldwide
basis. 
Please note my new email address: [EMAIL PROTECTED] 

http://www.thomson.net/ 

----Original Message-----
From: Rick Reumann [mailto:[EMAIL PROTECTED]
Sent: 11 March 2003 18:18
To: Struts Users Mailing List
Subject: Re: How define a DynaActionForm to display a collection ?


On Tue, 11 Mar 2003 17:36:09 +0100
Heligon Sandra <[EMAIL PROTECTED]> wrote:

> Has someone an example of struts-config.xml file and
> a such SetUpAction with DynaActionForm and Collection ?

In a form-bean declarations, where YourDyanForm is a subclass of a
DynaActionForm(DynaValidatorForm):

<form-bean name="projectForm"
dynamic="true" type="foo.bar.YourDyanForm">

 { snip }
<form-property name="myCollection" type="java.util.ArrayList"/>        
 { snip }
</form-bean>


Then in you Action class...


execute(..) {
        ArrayList someList = someBusinessClass.getMeListOfObjectsIneed();
        formBean.set("myCollection" someList );

        //forward to jsp page
}


The reason you'll want to subclass DynaActionForm is if you do some
validation you probably will have to override the reset method.  

-- 
Rick Reumann

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

Reply via email to