commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hasan Turksoy" <>
Subject [validator] intRange(between 0-100) validation fails for 1234 value because of a locale issue
Date Wed, 28 Feb 2007 18:14:41 GMT
hi all,

i am using an intRange validator together with an integer converter for my
input field.. code is like below;
<h:inputtext value="..myIntField" ...>
 <f:converter converterId="org.apache.shale.converter.Integer" />
 <s:commonsvalidator type="intRange" min="5" max="100" ... />
 <h:inputtext />

this means; my field will be validated for the 5<->100 range with an integer
value which will be converted by the shale's "
org.apache.shale.validator.converter.IntegerConverter" class...

if i enter values less than 1000; validator(GenericValidator class) is
working as expected... But, if i enter values more than 1000, then, it gives
a validation error saying my field's value(1234) must be integer!
This is because when i entered a value like 1234, converter converts my
value to string (validator-rules need string value to make integer
validation) as "123.4".. so, it puts a thousand separator while converting
my value to string... in this case, GenericTypeValidator's "formatInt"
method fails while creating a new Integer from this string... It's trying to
do like;
"return new Integer("123.4");"...

why this "formatInt(String value)" method of GenericTypeValidator is NOT
using overridden "formatInt(String value, Locale locale);" method with null
locale parameter?.. However, if it did like that; it will use the default
locale while parsing my string to integer... and it will work as expected...

best regards,


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