Thanks for the input.  I did some more research and I think I understand the
forms a little better.

The following code will create a DynaActionForm with one String field:

                FormBeanConfig formBean = new FormBeanConfig();
                FormPropertyConfig fpc = null;

                fpc = new FormPropertyConfig();
                fpc.setName("testField1");
                fpc.setType(java.lang.String.class.getName());
                fpc.setInitial("testField1Value");
                
                formBean.addFormPropertyConfig(fpc);
        
formBean.setType(org.apache.struts.action.DynaActionForm.class.getName());
                formBean.freeze();

                DynaActionFormClass dFC =
DynaActionFormClass.createDynaActionFormClass(formBean);
                DynaActionForm dynaForm = (DynaActionForm)
dFC.newInstance();


I think I know the answer already (my apologies), but will this code break
with new releases of struts.

Thanks

Edgar

> -----Original Message-----
> From: Nick [mailto:[EMAIL PROTECTED] 
> Sent: Monday, October 13, 2003 2:41 PM
> To: Struts Users Mailing List
> Subject: Re: DynaActionForms
> 
> 
> I do not believe that you can do dynamically add fields to a 
> DynaForm, as the config is frozen at app startup.  Might work 
> with an internal HashMap though.
> 
> On Mon, Oct 13, 2003 at 03:31:32PM -0400, Chen, Gin wrote:
> > I'm assuming that he meant create a new property that is 
> not already 
> > defined in the struts-config. In which case I think your 
> reply would 
> > fail with an property not found type exception. :-/
> > One way around this is to have a Hashmap within the 
> hashmapped dynaform.
> > That will allow you to do something like:
> > 
> > Hashmap myDynaproperties = 
> (Hashmap)myDynaform.get("dynaProperties");
> > myDynaproperties.set("foo", bar);
> > Etc.
> > 
> > Another possibility (although I havent tried it) is to operate 
> > directly on the map.
> > 
> > myDynaproperties.getMap().put("foo", bar);
> > 
> > -Tim
> > 
> > -----Original Message-----
> > From: Carlos Sanchez [mailto:[EMAIL PROTECTED]
> > Sent: Monday, October 13, 2003 3:21 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: DynaActionForms
> > 
> > 
> > yourdynaform.set("propertyname",propertyvalue);
> > 
> > > -----Mensaje original-----
> > > De: Edgar P Dollin [mailto:[EMAIL PROTECTED]
> > > Enviado el: lunes, 13 de octubre de 2003 19:35
> > > Para: Struts Users Mailing List
> > > Asunto: DynaActionForms
> > > 
> > > 
> > > I have an application with configuration files already.
> > > Rather than have struts-config configure DynaForms, I would 
> > > like to populate the forms myself.
> > > 
> > > Does anyone have any experience with how this behaves in struts?
> > > 
> > > Thanks
> > > 
> > > Edgar
> > > 
> > > 
> --------------------------------------------------------------------
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: 
> [EMAIL PROTECTED]
> > > 
> > > 
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> -- 
> Nick Heudecker
> SystemMobile, Inc.
> Email: [EMAIL PROTECTED]
> Web: http://www.systemmobile.com
> 

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

Reply via email to