commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Li Zhang" <Li.Zh...@aeso.ca>
Subject RE: [commons beanutil] - null, LongConverter, where (or when) should a new converted be registered?
Date Thu, 24 Aug 2006 15:33:08 GMT
You don't have to write your own. The LongConverter has a constructor that you can pass in
a default value. If you register an instance of the LongConverter created using this constructor
with a null value, it will give you null instead of 0. You can put the following code somewhere
in your application context, or servlet, or just as you said in the constructor of a singleton
of your app.

        BeanUtils.register(new LongConverter(null),Long.class); 



-----Original Message-----
From: German Sibay [mailto:gsibay@hexacta.com] 
Sent: Thursday, August 24, 2006 8:51 AM
To: Jakarta Commons Users List
Subject: [commons beanutil] - null, LongConverter, where (or when) should a new converted
be registered?

Hi
While working with BeanUtils I found that the default LongConverter converts a null to a Long
0. I needed a null so I wrote my own Converter. 
The question is where should I put it? 
I don´t really know where is that the converters are initialized the first time.
Must I register this converter every time before using BeanUtils.setProperty? Is Ok if I access
beanUtils through a singleton created by my witch registers the converter in the constructor?
Where in my application should I register my converter?
Thanks!

Germán Sibay.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


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