commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: BeanUtils.copyProperties and null properties
Date Fri, 04 Apr 2003 16:41:13 GMT
hi Budi

i think that you should be able to solve this by registering a 
FloatConverter with a null default value. take a look at the java docs for 
more details but i think that calling

ConvertUtils.register( new FloatConverter(null), Float.class )

when during initialization should work. (if it doesn't then you'll need to 
look at creating a custom Converter implementation - see the beanutils 
package documentation.)

- robert

On Friday, April 4, 2003, at 05:48 AM, Budi Rostiarso wrote:

> hi to all,
> i have a problem which i think is a usual problem, but i cant find the
> answer in commons forum, so please help :)
>
> Here we go:
> i'm trying to copy properties from Struts' ActionForm to my POJO, and
> vice versa.
> All properties from ActionForm are String, as suggested,
> and most of the properties in my POJO are Float objects, which
> correspond to db column.
>
> My problem is when the user send back the input form, and i use
> BeanUtils.copyProperties to copy the content of AF to my POJO, all the
> empty property string turns into default object.
> For example the from the empty String i get a Float object with value of
> 0.0, which isn't what i need.
> (i just need null, so i can update the db column with null value, not
> 0.0 value).
>
> Is this the default behavior of BeanUtils.copyProperties? if its so, how
> can i get around this?
>
> If you need further information, i'll be glad to provide.
>
>
> Thanks in advance
>
>
> Ross.
>
>
>
> ---------------------------------------------------------------------
> 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