On Fri, 5 Jul 2002, Boyalla, Raveendra wrote:

> Date: Fri, 5 Jul 2002 11:59:54 -0400
> From: "Boyalla, Raveendra" <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
> Subject: DynaActionForm and Nested property -- (to Craig)
>
> Hi Craig,
>
> this is my form bean.
>
>
> <form-bean      name="addPCCompanyForm"
>                     type="org.apache.struts.action.DynaActionForm">
>
>               <form-property name="pcCompany"
> type="rb.pc.vo.pcCompanies.PCCompanyVO"/>
>
>     </form-bean>
>
>
>
> and in form
>
> <html:text property="pcCompany.companyName" size="30" maxlength="30"/>
>
>
> java.lang.IllegalArgumentException: Null property value for 'pcCompany'
>       at
> org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.j
> ava:693)
>       at
> org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:74
> 1)
>       at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:723)
>
>
> It seems I need to initialize form-bean   property pcCompany to new
> rb.pc.vo.pcCompanies.PCCompanyVO().
>

Yep ... you sure do.

>
> Please help me out so that I can change all my form beans to DynaActionForm
> having nested properties.
>

The approach I generally take is to do this sort of thing is to subclass
DynaActionForm with a class that only has a reset() method (and optionally
a validate() method if you need one), and do the setup in reset().  This
works because reset() is always called when Struts creates an instance of
this form bean for you (in 1.1 -- it wasn't always true in 1.0), so it
makes a good spot to do initialization like this.

> Thanks to Struts Authors for making life easier.
>

You're welcome :-).

> Raveendra Boyalla
>

Craig


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

Reply via email to