I've always found that BeanUtils doesn't like BigDecimal and use type string then convert to BigDecimal before passing it up to the model . If you don't want to use string then perhaps Double or even its primitive (if you can get away with it) might work for you.


On 11 Feb 2004, at 11:47, Marco Mistroni wrote:


Hi all,
In my app I am using a DynaActionForm to retrieve
Input values.
I have one problem: one field of the bean is of type BigDecimal.. in the
Jsp I am setting the default initial value of zero, but this does not
prevent the silly user from deleting the zero and leave the field blank.
At that point, when the form is submitted I receive an exception saying
that
There was an exception in the conversion.
11/02/04 10:41:39:688 GMT] 6b75e39b WebGroup E SRVE0026E: [Servlet
Error]-[BeanUtils.populate]:
org.apache.commons.beanutils.ConversionException: Zero length BigDecimal
at
org.apache.commons.beanutils.converters.BigDecimalConverter.convert(Big D
ecimalConverter.java:162)
at
org.apache.commons.beanutils.ConvertUtils.convert(ConvertUtils.java: 373)
at
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:903)



Are there any other workaround other than using a 'String' copy of the field That is used as input, and then in the validate method of the bean I retrieve this string value and build a BigDecimal out of it?

How and where can I catch the ConversionException?

Thanx in advance and regards
        marco



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to