You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by bu...@apache.org on 2004/03/14 23:02:16 UTC

DO NOT REPLY [Bug 27652] New: - NumberValidator's error messages are localized, but parsing/formatting is not

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=27652>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=27652

NumberValidator's error messages are localized, but parsing/formatting is not

           Summary: NumberValidator's error messages are localized, but
                    parsing/formatting is not
           Product: Tapestry
           Version: 3.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Framework
        AssignedTo: tapestry-dev@jakarta.apache.org
        ReportedBy: davide.orlandi.due@synago.it


Error messages from NumberValidator are formatted using locale settings (since 
they are built from MessageFormat.format()) but parsing and formatting is not.

So, for example, if the minimum value constraint is set to 12345, an user 
typing "5000" in a ValidField would get this error:
"test numeric field must not be smaller than 12,345."

And typing "12,345" (pasting exactly from the error message) he would get:
"test numeric field must be a numeric value."

This can be quite misleading for users, especially in non-english locales: an 
italian ResourceBundle of ValidationStrings would display 12345 as "12.345" 
(yes, with the dot -- stupid locale rules :(  ).

Solutions: NumberValidator should format/parse using a localized NumberFormat 
(not so easy) or (easier) minimum and maximum should be toString()ed before 
passing them to formatString().


Tested code (using Tapestry 3.0 beta 4 and Tomcat 5.0.18):

--- Home.page ---

<page-specification class="org.apache.tapestry.html.BasePage">
    <property-specification name="numericValue" type="java.lang.Integer" />
    <bean name="validator" class="org.apache.tapestry.valid.NumberValidator">
        <set-property name="minimum" expression="12345" />
    </bean>
    <bean name="delegate" 
class="org.apache.tapestry.valid.ValidationDelegate" />
</page-specification>

--- Home.html ---

<html><body>
    <div jwcid="@Delegator" delegate="ognl:beans.delegate.firstError" />
    <form jwcid="@Form" delegate="ognl:beans.delegate">
        <input jwcid="@ValidField" validator="ognl:beans.validator"
            displayName="test numeric field" value="ognl:numericValue" />
        <input jwcid="@Submit" />
    </form>
</body></html>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org