On Thu, 21 Feb 2002, Porter, Roy wrote:

> Date: Thu, 21 Feb 2002 09:03:02 -0000
> From: "Porter, Roy" <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>
> To: 'Struts Developers List' <[EMAIL PROTECTED]>
> Subject: RE: DynaActionFormClass & set-property
>
> I'm trying to add regular Javabean style properties, as well as dynamic
> properties.
>

Ah ... then you're not going to like the current implementations of
DynaBeans very much.  They currently represent themselves as having *only*
the set of dynamic properties that are defined.

> an excerpt from the struts-config would be something like:
>
> <form-bean name="AddressForm" type="com.xxxxx.XXDynaActionForm"
> dynamic="true" className="com.xxxxx.struts.config.XXFormBeanConfig" >
>       <set-property property="voClassName"
> value="com.xxxxx.AddressTypeVO"/>
>       <set-property property="converterClassName"
> value="com.xxxxx.AddressType"/>
>       <form-property name="add1" type="java.lang.String"/>
>       <form-property name="add2" type="java.lang.String"/>
>       <form-property name="add3" type="java.lang.String"/>
> </form-bean>
>
> So in effect, the XXDynaActionForm class simply adds 2 properties to the
> standard DynaActionForm, and likewise for the XXFormBeanConfig class.
>

What makes voClassName and converterClassName any different than any other
dynamic property?  Why can't you just declare them with <form-property>
elements like "add1", "add2", and "add3"?

> According the 1.1 dtd this is allowable.
>
> If it's not obvious from the above, what I'm trying to do is to write as
> little code as possible ....
> there'll be the one ActionFormClass, using dynamic properties. As the
> project is using EJB, the Action class will convert the dynamic properties
> to the relevant Value Object type using the specifined converter, before
> invoking the required business object.
>
> I could have the voClassName, and converterClassName as form-property's with
> an initial value. But, would these not then get cleared on calling the reset
> method ?
>

If you declared them as standard dynamic properties (with
<form-property>), they would get initialized (and cleared) to null.

> Roy.
>

Craig


> -----Original Message-----
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: 21 February 2002 00:14
> To: Struts Developers List
> Subject: Re: DynaActionFormClass & set-property
>
>
>
>
> On Wed, 20 Feb 2002, Roy Porter wrote:
>
> >
> > If you extend the DynaActionFormClass to add your own properties, the
> > current code doesn't seem to copy these properties to the DynaActionForm
> > class when it creates it.
> >
>
> By "add your own properties", do you mean adding your own *dynamic*
> properties, or regular JavaBeans style properties?  Only the former are
> used in DynaActionFormClass.
>
> > In tracing the code through, the DynaActionFormClass gets initialized
> > correctly with the properties form the struts-config file, but there
> > doesn't seem to be any code to copy these over into the Form.
> >
>
> PropertyUtils (which is what the form tags use underneath the covers)
> understands what to do with DynaBeans -- could you supply an example of
> what you are trying to do?
>
> > Is there any specific way the properties should be created, or has this
> > code just not been written yet ?
> >
>
> I guess I've been assuming that people would just define what they need in
> struts-config.xml and not have to subclass for this purpose.  The only
> time you should need to subclass would be to implement a custom reset() or
> validate() method.
>
> > Roy.
> >
>
> Craig
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


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

Reply via email to