commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amir Nashat" <>
Subject BeanUtils SqlConversion
Date Wed, 10 Mar 2004 02:46:32 GMT


> Why not?  Can't you just re-register the standard converters with the

> that return default values instead of errors?




I'm not familiar with how you can re-register the standard converter
with another version. The BeanUtils.populate() method encapsulates the
eventual call to the SqlDateConverter class which throws the
ConversionException. I don't see any way of specifying in the BeanUtils
class how to use a modified SqlDateConverter with a default value
enabled. If you know how you can enable this please provide a code





> Personally, I would not choose this strategy, because the failed
conversions are

> just hiding a problem that is going to bite you later.  Instead, I
would set up

> a validation strategy to check the incoming values to make sure they

> syntactically correct and will not cause conversion errors.


> This is exactly why Struts encourages you to use Strings for form bean

> properties, for example.



I practice this same procedure as well of using Strings for form bean
properties. However, in my case it's not performing the conversion from
the form bean to some transfer object. Rather, I'm converting data from
the transfer object to the form bean. This is causing the exception. A
validation strategy works in cases where requirements are not fulfilled.
However, you can still have date fields that are nullable. In this case
you will still encounter the ConversionException.


Robert's solution of subclassing the BeanUtils class will work. I just
am leery of doing this because it seems as if the problem should really
be addressed in the BeanUtils class. Unless a better solution is
proposed, I'll probably subclass it until a fix to the
ConversionException is implemented.


Does anyone have any thoughts out there about this?







  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message