Hello,
I am aware that there is a switch to allow for a default value but if
you use the BeanUtils component this switch is not available to set. I
am wondering if there is any way to:
1) Specify a default value and use that value
2) If not the first option then to ignore the conversion all together
and move on with the next conversion
I am curious as to whether or not the BeanUtils component has created a
bug in its implementation or missed this fact?
Anybody out there have any suggestions?
Thanks!
Amir
>hi
>
>i think that the idea is that if you don't want a conversion exception
>to be thrown, you should specify a default.
>
>- robert
>> Hello All,
>>
>>
>>
>> I've been having a small problem with the BeanUtils utility. I'm
>> attempting to perform a copy of a java.sql.Date field, which can be
>> null, to a bean. The problem I am getting is that when the field is
>> null
>> I get a ConverstionException. After inspecting the code I found that
>> the
>> SqlConverter class is called and the convert() checks the following :
>>
>>
>>
>> if (value == null) {
>>
>> if (useDefault) {
>>
>> return (defaultValue);
>>
>> } else {
>>
>> throw new ConversionException("No value specified");
>>
>> }
>>
>> }
>>
>>
>>
>> I am wondering why the conversion exception is thrown in the first
>> place. Couldn't the check for null return the default value else no
>> value at all and skip that attribute? Also, for anyone out there that
>> has to perform type conversion and copy properties (of which some
date
>> attributes can be null) to a bean what is your implementation? How
are
>> you avoiding my problem?
>>
>>
>>
>> Thank you for your help.
>>
>>
>>
>> Amir
>>
>>
>>