commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject RE: Transferring Data from ValueObjects into DynaBeans
Date Tue, 11 Nov 2003 06:56:11 GMT
Quoting "Sumit S." <sumits@virtusa.com>:

> But hang on....Would this not mean that the WrapDynaBean is actually going to
> hold the "Bean" instance internally ? If that is what I want to avoid (For eg
> not sending over the Structs ActionForm to the application layer) then the
> wrapped dyna bean will not suffice....
> 
> We will need to construct a DynaBean by introspecting the given bean and
> setting up the DynaBean's properties...(something akin to what I have done)
> 
> Thoughts ?
> 

WrapDynaBean does indeed maintain a reference to the bean that is being wrapped.
 That's not a problem in a data transfer scenario, as long as the underlying
bean is Serializable (as a Struts ActionForm is), because your business tier
doesn't need to interact with the Struts ActionForm API -- only the DynaBean
API.

If you really don't like the wrapping, then consider PropertyUtils.describe()
which just gives you back a Map of the name-value pairs on any standard or dyna
bean instance.

Craig


> 
> -----Original Message-----
> From: Sumit S. 
> Sent: Monday, November 10, 2003 11:53 PM
> To: 'Jakarta Commons Users List'
> Subject: RE: Transferring Data from ValueObjects into DynaBeans
> 
> 
> Thanks,
>    Went thru the source code of the WrapDynaBean...Does the same thing as
> what I am doing here but additionally supports indexed & mapped
> properties...So makes sense to use the WrapDynaBean...
> 
> Thanks again
> Sumit
> 
> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Monday, November 10, 2003 10:49 PM
> To: Jakarta Commons Users List
> Subject: Re: Transferring Data from ValueObjects into DynaBeans
> 
> 
> Quoting "Sumit S." <sumits@virtusa.com>:
> 
> > Hi,
> >    Is there a standard way of describing the DynaProperty array for
> creating
> > a DynaBean into which I can populate data from a Value Object using
> > PropertyUtils.copyProperties (...)
> > 
> >   For eg, when we are getting data from a resultset and use the
> > ResultSetDynaClass
> > 
> >    BasicDynaClass bdc = new BasicDynaClass("foo", BasicDynaBean.class,
> > rsdc.getDynaProperties());
> > 
> >  Is there a way to set the DynaProperties of the DynaBean when bringing
> the
> > data over from a ValueObject (Say a struts based action form)
> > 
> >   What I have done as of now, is implemented a piece of code to introspect
> > the ActionForm and create an array of DynaProperty objects that I am
> passing
> > to the BasicDynaClass structure.
> > 
> > 				propertyDescriptor = propertyDescriptors[i];		 
> > 				propertyType = propertyDescriptor.getPropertyType();				
> > 				propertyName = propertyDescriptor.getName();			
> > 				dynaProperty = new DynaProperty(propertyName, propertyType);
> > 
> > Add all the dynaProperty Objects to an array and pass it to the
> > constructor....
> > 
> > Is there another way ?
> > 				
> > 
> 
> If you just want to copy the properties of your transfer object to set up a
> new
> DynaClass, check out the WrapDynaBean class.
> 
>   MyValueObject mvo = ...;
>   DynaBean dynabean = new WrapDynaBean(mvo);
> 
> 
> 
> >  
> > Thanks
> > Sumit
> > 
> 
> 
> Craig
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message