struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hubert Rabago" <>
Subject Re: FormDef
Date Wed, 02 Aug 2006 22:48:47 GMT
On 8/2/06, Michael Jouravlev <> wrote:
> On 7/20/06, Hubert Rabago <> wrote:
> > FormDef support nested beans, and nested collections of beans.  If you
> > had a nested Address object, your form would look like:
> >
> > <html:text property="name"/>
> > <html:text property="hireDate"/>
> > <html:text property="address.zipCode"/>
> In your example Address is nested within ActionForm, right?

No.  What happens is an ActionForm is nested within an ActionForm.

((DynaBean) form).get("address") will return another DynaBean.

What if I
> have an object like Person having Address as its member. All
> properties are strongly-typed so I do not want to expose them for I/O,
> instead I want to have autogenerated ActionForm fields so that I could
> redisplay them on error. Say I do not nest Persion inside ActionForm.
> Can I still somehow have a string property inside my ActionForm that
> corresponds to Person.Address? Can this property be autogenerated?

This is how FormDef works.  Of course, you'll have to tell FormDef
about the address form, but that's very easy:

    <form name="addressForm"

    <form name="employeeForm"

        <!-- specify that our address field should use addressForm -->
        <field property="address" formName="addressForm"/>

FormUtils.getFormValues() and setFormValues() takes care of handling
the nested objects, instantiating them as needed.

As you can imagine, they can go multiple levels, all nesting
Stringified versions of your business objects.  In one of my sample
apps, I have a "companyForm" with an "addressForm" and a collection of
"employeeForm" objects, with each employee having its own
"addressForm" nested form.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message