You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Brian Topping <to...@digidemic.com> on 2002/11/19 01:25:45 UTC
FW: PropertyUtils.copyProperties() usage in 1.1-b2
This didn't seem to get much interest on struts-user except from Craig, so I
thought I would move the question over here.
Any thoughts appreciated, not sure what I am doing wrong, but down at the
bottom, I think I've dissected this problem pretty well.
Thanks for any consideration,
-b
-----Original Message-----
From: Brian Topping
Sent: Sunday, November 17, 2002 3:20 AM
To: Struts Users Mailing List
Subject: RE: PropertyUtils.copyProperties() usage in 1.1-b2
Craig, Rana,
thanks for your responses, hoping you guys can provide some input:
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Subject: Re: PropertyUtils.copyProperties() usage in 1.1-b2
>
> > I'm trying to figure out what I am doing wrong with
> > PropertyUtils.copyProperties(). From within my Action, I have:
> >
> > User user = <bean>;
> > DynaActionForm regForm = (DynaActionForm) form;
> > PropertyUtils.copyProperties(regForm, user);
> >
> > When I look at what copyProperties is doing, it's getting a
> > PropertyDescriptor array from getPropertyDescriptors() with the user
> > bean correctly, then it iteratively tries to see if the
> regForm has any
> > of the properties found in the user bean. But calling
> > getPropertyDescriptor(regForm, <fieldname>) seems to be
> comparing the
> > (correct) field names from the bean against the *structure* of the
> > DynaActionForm component (i.e. the multipartRequestHandler,
> dynaClass,
> > servlet, etc), instead of the DynaFields that I set up in my
> > <form-bean/>.
> >
>
> Which CVS version number of PropertyUtils are you looking at
> (second line
> of the sources? The version I'm looking at, 1.32 (i.e. the current
> nightly builds), does not call getPropertyDescriptors() on a DynaBean.
K, here's what I'm seeing under PropertyUtils 1.32:
in copyProperties:
orig is neither Map nor DynaBean, so line 283 calls
getPropertyDescriptors(orig). Then, for each readMethod in the result, line
296 has:
String name = origDescriptors[i].getName();
if (getPropertyDescriptor(dest, name) != null) {
But getting into getPropertyDescriptor(), line 869 calls
getPropertyDescriptors(bean). If the dest is a DynaBean, I'm not seeing
where the "instanceof DynaBean" is -- it simply calls
Introspector.getBeanInfo().getPropertyDescriptors(), but the result of
getBeanInfo doesn't know anything about DynaBeans.
What am I missing here? Rana says this is working and appreciate his input,
especially with the release notes reference (thanks!) But tracing through
the code and triple-checking at the beans (they both have a "name" property),
I still can't see how this is going to work, and in practice, the destination
DynaBean is untouched.
Thanks again,
-b
--
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>