You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Boyalla, Raveendra" <Ra...@dfa.state.ny.us> on 2002/08/05 16:31:47 UTC

RE: DynaActionForm and Nested property -- (to Craig)

Craig


I have implemented Nested property, But I feel the way I have implemented is
wrong.
I am also proposing an alternative approach in PropertyUtils.
Please First see Original Message  at the end

Now  
if I have a nested property like this, I need to initialize new PcCompany().
<html:text property="pcCompany.companyName" size="30" maxlength="30"/>

if I have property like  pcCompany.address.streetName  then I need to
intialize new PcCompany() and new Address()

If have more nested  I may have to do the same for all.

But what I followed is, I declared pcCompany=new PcOmpany() in form 
and address=new Address() in PcCompany Class,  Which means I dont have to do
that in reset() method.


It is working fine. but I will have No null objects in any of my Classes,
Which inturn is giving some small problems. I feel reset() method is an
extra burden in case of Big objects having many sub objects.

Instead I propose to do the following in PropertyUtils calss or in a new
Subclass.

While setting data from FormBean to JSP
	If property is null asume the value of nested property is null, for
example 
	in nested property pcCompany.address.streetName  if address is null
propertyUtils should assume that street name is null.

While Getting data from JSP to FormBean
	In nested property pcCompany.address.streetName  if
pcCompany.address.streetName value!=null and !="" and address==null then
propertyUtils should initialize to new Address() and set the value.

This way my bussiness objects can know which property Object is having data
by checking for null.


In case of reset() doing initialization all the property objects like
Address() will be initialized even if it holds no values in it.

Please ask me if you need some calrification.


Thank you

Raveendra Boyalla



-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Friday, July 05, 2002 2:09 PM
To: Struts Users Mailing List
Subject: Re: DynaActionForm and Nested property -- (to Craig)


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

> Date: Fri, 5 Jul 2002 11:59:54 -0400
> From: "Boyalla, Raveendra" <Ra...@dfa.state.ny.us>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: 'Struts Users Mailing List' <st...@jakarta.apache.org>
> 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
>



 
	




--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: DynaActionForm and Nested property -- (to Craig)

Posted by MAXMOUSE <ma...@ciindia.com>.
Hi,
  in the form bean declaration of a dynamic action form give the attribute
dynamic="true" it will solve the problem regarding the dynaactionform that
you have.
bye
muruges
----- Original Message -----
From: "Boyalla, Raveendra" <Ra...@dfa.state.ny.us>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Monday, August 05, 2002 8:01 PM
Subject: RE: DynaActionForm and Nested property -- (to Craig)


> Craig
>
>
> I have implemented Nested property, But I feel the way I have implemented
is
> wrong.
> I am also proposing an alternative approach in PropertyUtils.
> Please First see Original Message  at the end
>
> Now
> if I have a nested property like this, I need to initialize new
PcCompany().
> <html:text property="pcCompany.companyName" size="30" maxlength="30"/>
>
> if I have property like  pcCompany.address.streetName  then I need to
> intialize new PcCompany() and new Address()
>
> If have more nested  I may have to do the same for all.
>
> But what I followed is, I declared pcCompany=new PcOmpany() in form
> and address=new Address() in PcCompany Class,  Which means I dont have to
do
> that in reset() method.
>
>
> It is working fine. but I will have No null objects in any of my Classes,
> Which inturn is giving some small problems. I feel reset() method is an
> extra burden in case of Big objects having many sub objects.
>
> Instead I propose to do the following in PropertyUtils calss or in a new
> Subclass.
>
> While setting data from FormBean to JSP
> If property is null asume the value of nested property is null, for
> example
> in nested property pcCompany.address.streetName  if address is null
> propertyUtils should assume that street name is null.
>
> While Getting data from JSP to FormBean
> In nested property pcCompany.address.streetName  if
> pcCompany.address.streetName value!=null and !="" and address==null then
> propertyUtils should initialize to new Address() and set the value.
>
> This way my bussiness objects can know which property Object is having
data
> by checking for null.
>
>
> In case of reset() doing initialization all the property objects like
> Address() will be initialized even if it holds no values in it.
>
> Please ask me if you need some calrification.
>
>
> Thank you
>
> Raveendra Boyalla
>
>
>
> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Friday, July 05, 2002 2:09 PM
> To: Struts Users Mailing List
> Subject: Re: DynaActionForm and Nested property -- (to Craig)
>
>
> On Fri, 5 Jul 2002, Boyalla, Raveendra wrote:
>
> > Date: Fri, 5 Jul 2002 11:59:54 -0400
> > From: "Boyalla, Raveendra" <Ra...@dfa.state.ny.us>
> > Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> > To: 'Struts Users Mailing List' <st...@jakarta.apache.org>
> > 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
> >
>
>
>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>