You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2013/01/18 19:02:21 UTC
[S1] Validator does not respect locale when validating double value?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
All,
I'm running Struts 1.3.10 (with commons-validator 1.3.1), and I'm
trying to validate (and subsequently parse) a floating-point value as
a double.
My validator configuration looks like this (I apologize for it's
potential unreadability):
<field property="maxAgeMonths"
page="3"
depends="required,maxlength,double,doubleRange">
<arg position="1" name="maxlength" key="${var:maxlength}"
resource="false" />
<var><var-name>maxlength</var-name><var-value>8</var-value></var>
<var><var-name>min</var-name><var-value>-10.0</var-value></var>
<var><var-name>max</var-name><var-value>11.99</var-value></var>
<msg name="doubleRange" bundle="Staff" key="error.age-out-of-range" />
</field>
In my session, the value of org.apache.struts.action.LOCALE is "es",
so Spanish. My UI is coming-up in Spanish, too.
When I try to submit "3,77" as the "max age", I get a message that the
field value is not a valid "double".
If I change the value to "3.77", I get no errors, and of course my
code (somewhat) correctly parses the value to 377 months because, in
Spanish, the period means a grouping separator and not a decimal point.
I have not altered the standard definition of the "double" validator:
I'm using whatever comes in
/org/apache/struts/validator/validator-rules.xml.
Before I go digging-through the code Struts/commons-validator to find
out exactly what might be wrong, can anyone give me any suggestions at
to what I might be missing?
Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEAREIAAYFAlD5ji0ACgkQ9CaO5/Lv0PAMmACfWNa2HW7HZbcZpttLjNzHfZXk
R8cAn1+cSyS2l85kXndju57zz037OBmE
=Kpsg
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double value?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-chris
--
Christopher Schultz
Chief Technology Officer, Total Child Health Inc.
Technical Director, Center for Promotion of Child Development through Primary Care
tel: +1.410.807.4500 x20
tel: +1.888.4CHADIS (+1.888.424.2347)
email: cschultz@chadis.com
On Jan 18, 2013, at 16:38, Lukasz Lenart <lu...@apache.org> wrote:
> 2013/1/18 Christopher Schultz <ch...@christopherschultz.net>:
>> Honestly, I'm shocked that struts 1, which is at least 10 years old, still has a glaring internationalization bug like this.
>
> It isn't actively developed any more, that's the problem :-)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double value?
Posted by Lukasz Lenart <lu...@apache.org>.
2013/1/19 Christopher Schultz <ch...@christopherschultz.net>:
> So, is it worth filing a bug and attaching a patch, or should I just
> write my own validator and use that for my own uses?
Fill a bug and attach patch and write your own custom validator as well :-)
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double
value?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Łukasz,
On 1/18/13 4:38 PM, Lukasz Lenart wrote:
> 2013/1/18 Christopher Schultz <ch...@christopherschultz.net>:
>> Honestly, I'm shocked that struts 1, which is at least 10 years
>> old, still has a glaring internationalization bug like this.
>
> It isn't actively developed any more, that's the problem :-)
So, is it worth filing a bug and attaching a patch, or should I just
write my own validator and use that for my own uses?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEAREIAAYFAlD69U8ACgkQ9CaO5/Lv0PDHmgCfV4jOQquBS9SZ02KsbTvIXdav
SGgAoKD/vBZOzdumFH4itlv77rYtu02M
=FjbO
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double value?
Posted by Lukasz Lenart <lu...@apache.org>.
2013/1/18 Christopher Schultz <ch...@christopherschultz.net>:
> I've got an old web app that has used S1 for years, so that's why I'm using it. Don't worry, I'm not trying to launch a brand-new project using struts one.
:D
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double value?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
Łucaz,
On Jan 18, 2013, at 16:38, Lukasz Lenart <lu...@apache.org> wrote:
> 2013/1/18 Christopher Schultz <ch...@christopherschultz.net>:
>> Honestly, I'm shocked that struts 1, which is at least 10 years old, still has a glaring internationalization bug like this.
>
> It isn't actively developed any more, that's the problem :-)
I *did* know that, but I figured it would have been fixed while ago :-)
I've got an old web app that has used S1 for years, so that's why I'm using it. Don't worry, I'm not trying to launch a brand-new project using struts one.
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double value?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-chris
--
Christopher Schultz
Chief Technology Officer, Total Child Health Inc.
Technical Director, Center for Promotion of Child Development through Primary Care
tel: +1.410.807.4500 x20
tel: +1.888.4CHADIS (+1.888.424.2347)
email: cschultz@chadis.com
On Jan 18, 2013, at 16:38, Lukasz Lenart <lu...@apache.org> wrote:
> 2013/1/18 Christopher Schultz <ch...@christopherschultz.net>:
>> Honestly, I'm shocked that struts 1, which is at least 10 years old, still has a glaring internationalization bug like this.
>
> It isn't actively developed any more, that's the problem :-)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double value?
Posted by Lukasz Lenart <lu...@apache.org>.
2013/1/18 Christopher Schultz <ch...@christopherschultz.net>:
> Honestly, I'm shocked that struts 1, which is at least 10 years old, still has a glaring internationalization bug like this.
It isn't actively developed any more, that's the problem :-)
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double value?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
Łucaz,
On Jan 18, 2013, at 16:00, Lukasz Lenart <lu...@apache.org> wrote:
> 2013/1/18 Christopher Schultz <ch...@christopherschultz.net>:
>> The method validateDouble() totally ignores the user's Locale and
>> calls commons-validator's formatDouble(String) method instead of the
>> formatDouble(String,Locale) method.
>>
>> The same seems to be true for all the validate[NumberType] methods and
>> validate[NumberType]Range methods.
>>
>> This seems to be an i18n bug to me. Am I missing something?
>
> Looks like...
Thanks for the sanity check. It's a simple patch, one that I am more than willing to provide.
Honestly, I'm shocked that struts 1, which is at least 10 years old, still has a glaring internationalization bug like this.
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double value?
Posted by Lukasz Lenart <lu...@apache.org>.
2013/1/18 Christopher Schultz <ch...@christopherschultz.net>:
> The method validateDouble() totally ignores the user's Locale and
> calls commons-validator's formatDouble(String) method instead of the
> formatDouble(String,Locale) method.
>
> The same seems to be true for all the validate[NumberType] methods and
> validate[NumberType]Range methods.
>
> This seems to be an i18n bug to me. Am I missing something?
Looks like...
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S1] Validator does not respect locale when validating double
value?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
All,
On 1/18/13 1:02 PM, Christopher Schultz wrote:
> Before I go digging-through the code Struts/commons-validator to
> find out exactly what might be wrong, can anyone give me any
> suggestions at to what I might be missing?
Actually, it didn't take a lot of digging:
http://svn.apache.org/viewvc/struts/struts1/tags/STRUTS_1_3_10/core/src/main/java/org/apache/struts/validator/FieldChecks.java?view=markup
The method validateDouble() totally ignores the user's Locale and
calls commons-validator's formatDouble(String) method instead of the
formatDouble(String,Locale) method.
The same seems to be true for all the validate[NumberType] methods and
validate[NumberType]Range methods.
This seems to be an i18n bug to me. Am I missing something?
Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEAREIAAYFAlD5mq4ACgkQ9CaO5/Lv0PC8eACeLQwIIKTeKRovTsVjQL5J0Xzk
VygAoJUjB9SIHmSjI3PuYIw5kJhbQjc3
=REQ5
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org