Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Jakarta Beanutils - Conversion rules for null

843841May 27 2004 — edited Jun 9 2004
Hi all,

I am using the BeanUtils.copyProperties(target, source) method to copy my Struts ActionForm String-only fields into my Business JavaBean's typed fields (String, Boolean and Integer fields).

The thing I am having trouble understanding is if there is no request variable sent for a particular value, this value is null in the Struts action form - but the copyProperties method uses this null String to populate an Integer field on my business bean as new Integer(0) - and not simply populating this value with null.

This doesn't seem intuitive to me - if the HTML form had no value for a certain field, I expect both ActionForm and Business bean to also have a null value - the the form have the value "0", then I would expect this to get mapped through to new Integer(0) in the back end.

Is there any documentation that explain the default BeanUtils conversion rules, or ways or adjusting these rules programatically ?
I have browsed the jakarta site for a while, but not seem anything of immediate use, and google isn't helping at all !

Many thanks for you help,
Ben
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 7 2004
Added on May 27 2004
3 comments
657 views