You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Sumit S." <su...@virtusa.com> on 2003/11/10 17:03:40 UTC
Transferring Data from ValueObjects into DynaBeans
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 ?
Thanks
Sumit
Re: Transferring Data from ValueObjects into DynaBeans
Posted by "Craig R. McClanahan" <cr...@apache.org>.
Quoting "Sumit S." <su...@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