You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Richard Lamuette <tu...@laposte.net> on 2003/01/25 15:01:10 UTC

[BeanUtils] Registering converters. Help!!

BeanUtils v1.6 in Stuts 1.1b3
When trying to resolve the problem of populating form bean or business bean
with date types, I use :
   ConvertUtils.register ( new SqlDateLocaleConverter( Locale.getDefault(),
"dd/MM/yyyy") , java.sql.Date.class);
   ConvertUtils.register ( new StringLocaleConverter(
Locale.getDefault(),"dd/MM/yyyy") , String.class);

eveything works great by using BeansUtil.copyProperties(form,business)
* in my form bean, String type for my date
* in my business bean, java.sql.Date type for my date

But the problems appear when I add another property to my form and my
business bean,
* in my form bean, String type for my integer
* in my business bean, Integer type for my integer

BeanUtils copy in the string property of my form bean : dd/MM/yyyyMYINTEGER
Actually, it uses the same pattern "dd/MM/yyyy" for converting Integer to
String than for converting Date to String.
The problem is obviously there in the management of the different sources of
pattern in the Converters, the pattern is not related to the source type of
the conversion. Am I right ?
Thank you for your support.
Richard.


RE: [BeanUtils] Registering converters. Help!!

Posted by Richard Lamuette <tu...@laposte.net>.
Thank you Robert,
But after analyzing the code of BeanUtils, i rewrite my own Converters for
all native and wrappers conversion.
I fix the bug of the same pattern for DecimalFormat and SimpleDateFormat in
StringLocaleConverter. I can now convert dates and decimal values with a
relevant and different pattern.
Richard.

-----Message d'origine-----
De : robert burrell donkin [mailto:robertburrelldonkin@blueyonder.co.uk]
Envoye : lundi 27 janvier 2003 22:45
A : Jakarta Commons Users List
Objet : Re: [BeanUtils] Registering converters. Help!!


hi Richard

i'm not sure whether it's a bug or not - i'd need more detailed example
code.

there is one thing that it might be - if you pass in "dd/MM/yyyy" into the
IntegerLocaleConverter constructor - for example:

new IntegerLocaleConverter( Locale.getDefault(), "dd/MM/yyyy")

then you might get something similar to what you describe.

- robert

On Sunday, January 26, 2003, at 02:49 PM, Richard Lamuette wrote:

> yes, and it doesn't change the problem. Is there something I
> misunderstand ?
> Or is it a bug ?
> Need Help.
> Thank you.
> Richard.
>
> -----Message d'origine-----
> De : robert burrell donkin [mailto:robertburrelldonkin@blueyonder.co.uk]
> Envoye : samedi 25 janvier 2003 21:23
> A : Jakarta Commons Users List
> Objet : Re: [BeanUtils] Registering converters. Help!!
>
>
> hi Richard
>
> are you registering a converter (IntegerLocaleConverter, say) to perform
> the string-to-integer conversion?
>
> - robert
>
> On Saturday, January 25, 2003, at 02:01 PM, Richard Lamuette wrote:
>
>> BeanUtils v1.6 in Stuts 1.1b3
>> When trying to resolve the problem of populating form bean or business
>> bean
>> with date types, I use :
>>    ConvertUtils.register ( new SqlDateLocaleConverter( Locale.getDefault(
>> ),
>> "dd/MM/yyyy") , java.sql.Date.class);
>>    ConvertUtils.register ( new StringLocaleConverter(
>> Locale.getDefault(),"dd/MM/yyyy") , String.class);
>>
>> eveything works great by using BeansUtil.copyProperties(form,business)
>> * in my form bean, String type for my date
>> * in my business bean, java.sql.Date type for my date
>>
>> But the problems appear when I add another property to my form and my
>> business bean,
>> * in my form bean, String type for my integer
>> * in my business bean, Integer type for my integer
>>
>> BeanUtils copy in the string property of my form bean :
>> dd/MM/yyyyMYINTEGER
>> Actually, it uses the same pattern "dd/MM/yyyy" for converting Integer to
>> String than for converting Date to String.
>> The problem is obviously there in the management of the different sources
>> of
>> pattern in the Converters, the pattern is not related to the source type
>> of
>> the conversion. Am I right ?
>> Thank you for your support.
>> Richard.
>>
>>
>> --
>> To unsubscribe, e-mail:   <mailto:commons-user-
>> unsubscribe@jakarta.apache.
>> org>
>> For additional commands, e-mail: <mailto:commons-user-
>> help@jakarta.apache.
>> org>
>>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-user-help@jakarta.apache.
> org>
>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


Re: [BeanUtils] Registering converters. Help!!

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi Richard

i'm not sure whether it's a bug or not - i'd need more detailed example 
code.

there is one thing that it might be - if you pass in "dd/MM/yyyy" into the 
IntegerLocaleConverter constructor - for example:

new IntegerLocaleConverter( Locale.getDefault(), "dd/MM/yyyy")

then you might get something similar to what you describe.

- robert

On Sunday, January 26, 2003, at 02:49 PM, Richard Lamuette wrote:

> yes, and it doesn't change the problem. Is there something I 
> misunderstand ?
> Or is it a bug ?
> Need Help.
> Thank you.
> Richard.
>
> -----Message d'origine-----
> De : robert burrell donkin [mailto:robertburrelldonkin@blueyonder.co.uk]
> Envoye : samedi 25 janvier 2003 21:23
> A : Jakarta Commons Users List
> Objet : Re: [BeanUtils] Registering converters. Help!!
>
>
> hi Richard
>
> are you registering a converter (IntegerLocaleConverter, say) to perform
> the string-to-integer conversion?
>
> - robert
>
> On Saturday, January 25, 2003, at 02:01 PM, Richard Lamuette wrote:
>
>> BeanUtils v1.6 in Stuts 1.1b3
>> When trying to resolve the problem of populating form bean or business
>> bean
>> with date types, I use :
>>    ConvertUtils.register ( new SqlDateLocaleConverter( Locale.getDefault(
>> ),
>> "dd/MM/yyyy") , java.sql.Date.class);
>>    ConvertUtils.register ( new StringLocaleConverter(
>> Locale.getDefault(),"dd/MM/yyyy") , String.class);
>>
>> eveything works great by using BeansUtil.copyProperties(form,business)
>> * in my form bean, String type for my date
>> * in my business bean, java.sql.Date type for my date
>>
>> But the problems appear when I add another property to my form and my
>> business bean,
>> * in my form bean, String type for my integer
>> * in my business bean, Integer type for my integer
>>
>> BeanUtils copy in the string property of my form bean :
>> dd/MM/yyyyMYINTEGER
>> Actually, it uses the same pattern "dd/MM/yyyy" for converting Integer to
>> String than for converting Date to String.
>> The problem is obviously there in the management of the different sources
>> of
>> pattern in the Converters, the pattern is not related to the source type
>> of
>> the conversion. Am I right ?
>> Thank you for your support.
>> Richard.
>>
>>
>> --
>> To unsubscribe, e-mail:   <mailto:commons-user-
>> unsubscribe@jakarta.apache.
>> org>
>> For additional commands, e-mail: <mailto:commons-user-
>> help@jakarta.apache.
>> org>
>>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-user-help@jakarta.apache.
> org>
>


RE: [BeanUtils] Registering converters. Help!!

Posted by Richard Lamuette <tu...@laposte.net>.
yes, and it doesn't change the problem. Is there something I misunderstand ?
Or is it a bug ?
Need Help.
Thank you.
Richard.

-----Message d'origine-----
De : robert burrell donkin [mailto:robertburrelldonkin@blueyonder.co.uk]
Envoye : samedi 25 janvier 2003 21:23
A : Jakarta Commons Users List
Objet : Re: [BeanUtils] Registering converters. Help!!


hi Richard

are you registering a converter (IntegerLocaleConverter, say) to perform
the string-to-integer conversion?

- robert

On Saturday, January 25, 2003, at 02:01 PM, Richard Lamuette wrote:

> BeanUtils v1.6 in Stuts 1.1b3
> When trying to resolve the problem of populating form bean or business
> bean
> with date types, I use :
>    ConvertUtils.register ( new SqlDateLocaleConverter( Locale.getDefault(
> ),
> "dd/MM/yyyy") , java.sql.Date.class);
>    ConvertUtils.register ( new StringLocaleConverter(
> Locale.getDefault(),"dd/MM/yyyy") , String.class);
>
> eveything works great by using BeansUtil.copyProperties(form,business)
> * in my form bean, String type for my date
> * in my business bean, java.sql.Date type for my date
>
> But the problems appear when I add another property to my form and my
> business bean,
> * in my form bean, String type for my integer
> * in my business bean, Integer type for my integer
>
> BeanUtils copy in the string property of my form bean :
> dd/MM/yyyyMYINTEGER
> Actually, it uses the same pattern "dd/MM/yyyy" for converting Integer to
> String than for converting Date to String.
> The problem is obviously there in the management of the different sources
> of
> pattern in the Converters, the pattern is not related to the source type
> of
> the conversion. Am I right ?
> Thank you for your support.
> Richard.
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-user-help@jakarta.apache.
> org>
>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


Re: [BeanUtils] Registering converters. Help!!

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi Richard

are you registering a converter (IntegerLocaleConverter, say) to perform 
the string-to-integer conversion?

- robert

On Saturday, January 25, 2003, at 02:01 PM, Richard Lamuette wrote:

> BeanUtils v1.6 in Stuts 1.1b3
> When trying to resolve the problem of populating form bean or business 
> bean
> with date types, I use :
>    ConvertUtils.register ( new SqlDateLocaleConverter( Locale.getDefault(
> ),
> "dd/MM/yyyy") , java.sql.Date.class);
>    ConvertUtils.register ( new StringLocaleConverter(
> Locale.getDefault(),"dd/MM/yyyy") , String.class);
>
> eveything works great by using BeansUtil.copyProperties(form,business)
> * in my form bean, String type for my date
> * in my business bean, java.sql.Date type for my date
>
> But the problems appear when I add another property to my form and my
> business bean,
> * in my form bean, String type for my integer
> * in my business bean, Integer type for my integer
>
> BeanUtils copy in the string property of my form bean : 
> dd/MM/yyyyMYINTEGER
> Actually, it uses the same pattern "dd/MM/yyyy" for converting Integer to
> String than for converting Date to String.
> The problem is obviously there in the management of the different sources 
> of
> pattern in the Converters, the pattern is not related to the source type 
> of
> the conversion. Am I right ?
> Thank you for your support.
> Richard.
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-user-help@jakarta.apache.
> org>
>