File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes BeanUtils and null-properties. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "BeanUtils and null-properties." Watch "BeanUtils and null-properties." New topic

BeanUtils and null-properties.

Grigory O. Ptashko

Joined: Jan 26, 2006
Posts: 16

I try to use BeanUtils from commons project. I want to copy properties from one bean to another. The problem I have is when the source bean has a java.lang.String property which is null and the target bean has property of java.lang.Long. Using BeanUtils.copyProperties(target, source) set the target's property to 0 (zero). But I do not need this. I need the property to stay null also as in the source bean.

Here is the sample code:

Source bean:

Target Bean:

And the code:

Gives the following output:

Any ideas?

I agree. Here's the link:
subject: BeanUtils and null-properties.
jQuery in Action, 3rd edition