See comments below:


> cao> craigmcc    01/01/27 18:22:13
>
> cao>   Modified:    src/share/org/apache/struts/util ConvertUtils.java
> cao>   Log:
> cao>   Provide configurable default values for numeric conversions that
suffer from
> cao>   a NumberFormatException error.
>  
> This is a old flame but is it good idea to perform to/from String
> conversions in such munner? There are some undergrouond problems
> with it -
> 
> 1. Non valid value will be converted to the default value, but more
>    logical way in this situation is to generate exception with source
>    of problem description, etc. Default values may be an optional way,
>    for my mind. In general values must be tested for appropriate
>    values in conversion process.

Doesn't this violate one of the behaviors of Struts forms?  

If a Struts form is invalid, it is redisplayed to the user displaying the
values that the user actually entered.  Since the form bean is populated
using ConvertUtil, the bean my not contain the actual valued entered,
thus it cannot be redisplayed to the user as entered.

Seems to me that all form bean properties would have to be typeless 
(a String) in order to support the correct form behavior, which would suck.

What if the actual JavaBean spec compliant form bean was wrapped by some
sort of typeless dynamic proxy that would store the user entered value
and error message in the case of a conversion exception?  That would allow 
the form to redisplay the entered value while preserving the current 
automatic type conversion feature.

I'd be glad to implement this if you guys like the idea.

-Robert Quillen

Reply via email to