commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anon Myous <anonymous_needs_h...@yahoo.com>
Subject Re: BeanUtils Feature
Date Mon, 26 Jan 2004 18:14:01 GMT
Well, I went ahead and wrote an extension to the
BeanUtils class for my own with the needed method
borrowing heavily on the implementation of the
BeanUtils class. Hurray open source !!! Thank you
Craig, Matt for the inputs.
--- "Craig R. McClanahan" <craigmcc@apache.org> wrote:
> Quoting __matthewHawthorne <matth@apache.org>:
> 
> > Anon Myous wrote:
> >  > So what I am looking for from a API standpoint
> >  > something equivalent to
> BeanUtils.copyProperty(Object
> >  > dest, Object orig, List propertyList)
> >  > where propertyList is a list of properties of
> the orig
> >  > Bean that needs to be copied to the dest Bean.
> > 
> > 
> > Sorry, I think I may have misunderstood the
> situation.  I don't think 
> > that there is a built-in way to do this right now.
> > 
> > One solution is to manually loop though your list
> of properties and set 
> > then one-by-one.  Like this:
> > 
> > for prop in bean1Props {
> >    BeanUtils.copyProperty(newBean, prop, bean1)
> > }
> > 
> > for prop in bean2Props {
> >    BeanUtils.copyProperty(newBean, prop, bean2)
> > }
> > 
> > 
> > Your desire for a method such as:
> > 
> > BeanUtils.copyProperties(Object dest, Object orig,
> List propertyList)
> > 
> > Seems valid to me, as I've recently needed the
> same thing.  I've never 
> > worked on [beanutils], so I'm not really sure what
> the stance on such a 
> > method would be... Robert, any thoughts?
> > 
> 
> As the original developer of the code in BeanUtils,
> I don't have any particular
> problem with supporting something like this ... but
> it seems awfully easy to
> roll your own strategy as well:
> 
> * Create a HashMap
> 
> * From it, copy only the properties of your "origin"
>   bean that you really want to copy.
> 
> * Call BeanUtils.copyProperties() with this Map as
> the
>   origin bean, instead of the original bean.
> 
> Would that work?  (Of course, it depends on knowing
> that
> BeanUtils.copyProperties() is perfectly happy with
> an origin bean that is a
> Map, but that is a documented feature.)
> 
> Craig McClanahan
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------------------------------------------------
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