commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <>
Subject Re: [BeanUtils] default value for BigDecimalConverter
Date Thu, 06 Sep 2007 15:05:54 GMT
On 9/2/07, Tomáš Procházka <> wrote:
> Hi.
> I have question related ConvertUtilsBeans class.
> Why all Converters has defined default value, only BigDecimalConverter and BigIntegerConverter
not?  When I need populate any bean with BigDecimal it's fail on this if value is "". For
example forms in Strus framework. When I have Integer field and user send empty string BeanBindings
convert it to 0, but when I jave BigDecimal field get only:
> org.apache.commons.beanutils.ConversionException

I believe it was a mistake when BigDecimal / BigInteger converters
were added that they didn't provide a default value and wasn't
subsequently changed for compatibility reasons. You can simply
register instances of those converters with default values yourself to
overcome this:

Converter converter = new BigDecimalConverter(new BigDecimal("0.0"));
ConvertUtils.register(converter, BigDecimal.class);


> --
> Tomas Prochazka

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message