Wendy Smoak wrote:
From: "Cadariu, Mihai" <[EMAIL PROTECTED]>
I have two instances of the same form bean class, both containing some
properties filled, the rest being null. I would like to copy the non-null
properties from one form bean to the other. I tried using the
PropertyUtils.copyProperties or BeanUtils.copyProperties but they copy all
properties, whether they are null or not. Is there a way to tweak the
copying, so that only non-null values are overwritten?

I haven't done it, but you can use a BeanInfo class to control what
properties are exposed:
   http://java.sun.com/docs/books/tutorial/javabeans/beaninfo/

That wont work, though, if you don't know at design time which properties you need to copy and which to ignore. My first thought if that's an issue would be to describe() the source bean into a map, filter the null valued properties, then populate() the target bean. Seems a bit long-winded though. It might be worth asking on the BeanUtils list.

L.
--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to