You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Max Pimm (JIRA)" <ji...@apache.org> on 2007/10/16 11:06:38 UTC
[jira] Created: (WW-2254) Stringlength validator xhtml template
should be locale independent
Stringlength validator xhtml template should be locale independent
------------------------------------------------------------------
Key: WW-2254
URL: https://issues.apache.org/struts/browse/WW-2254
Project: Struts 2
Issue Type: Bug
Components: Views
Affects Versions: 2.0.9
Environment: Firefox 2
Reporter: Max Pimm
Priority: Minor
The freemarker template that generates client side validation for the xhtml theme (template/xhtml/form-close-validate.ftl) generates the javascript functions for different validators.
In the case of the stringlength validator there are a series of lines of code that are generated that may not work in locales that are not English. For example, if you define the maxLength to be 1000.
value.length > ${validator.maxLength}
in a Spanish locale outputs
value.length > 1,000
Which results in a string comparison rather than a number comparison.
To remedy this i have found two valid solutions.
1) Include number formating for freemarker: ${validator.maxLength?string("#")
2) Add javascript conversion to an int: parseInt(${validator.maxLength)
I have not tested either of these solutions in other browsers.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WW-2254) Stringlength validator xhtml template
should be locale independent
Posted by "Max Pimm (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/WW-2254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Max Pimm updated WW-2254:
-------------------------
Description:
The freemarker template that generates client side validation for the xhtml theme (template/xhtml/form-close-validate.ftl) generates the javascript functions for different validators.
In the case of the stringlength validator there are a series of lines of code that are generated that may not work in locales that are not English. For example, if you define the maxLength to be 1000.
value.length > ${validator.maxLength}
in a Spanish locale outputs
value.length > 1,000
Which results in a string comparison rather than a number comparison.
The solution that i've found is to force the formatting of maxLength and minLength in freemarker using ?string("#"). For example
value.length > ${validator.maxLength?string("#")
Which outputs the correct version.
value.length > 1000
I believe that all references to maxLength and minLength in form-close-validate.ft should use this. I haven't looked to see if there are other places in the file where a similar error could occur.
was:
The freemarker template that generates client side validation for the xhtml theme (template/xhtml/form-close-validate.ftl) generates the javascript functions for different validators.
In the case of the stringlength validator there are a series of lines of code that are generated that may not work in locales that are not English. For example, if you define the maxLength to be 1000.
value.length > ${validator.maxLength}
in a Spanish locale outputs
value.length > 1,000
Which results in a string comparison rather than a number comparison.
The solution that i've found is to force the formatting of maxLength and minLength in freemarker using ?string("#"). For example
${validator.maxLength?string("#")
I believe that all references to maxLength and minLength in form-close-validate.ft should use this. I haven't looked to see if there are other places in the file where a similar error could ocur.
> Stringlength validator xhtml template should be locale independent
> ------------------------------------------------------------------
>
> Key: WW-2254
> URL: https://issues.apache.org/struts/browse/WW-2254
> Project: Struts 2
> Issue Type: Bug
> Components: Views
> Affects Versions: 2.0.9
> Environment: Firefox 2
> Reporter: Max Pimm
> Priority: Minor
>
> The freemarker template that generates client side validation for the xhtml theme (template/xhtml/form-close-validate.ftl) generates the javascript functions for different validators.
> In the case of the stringlength validator there are a series of lines of code that are generated that may not work in locales that are not English. For example, if you define the maxLength to be 1000.
> value.length > ${validator.maxLength}
> in a Spanish locale outputs
> value.length > 1,000
> Which results in a string comparison rather than a number comparison.
> The solution that i've found is to force the formatting of maxLength and minLength in freemarker using ?string("#"). For example
> value.length > ${validator.maxLength?string("#")
> Which outputs the correct version.
> value.length > 1000
> I believe that all references to maxLength and minLength in form-close-validate.ft should use this. I haven't looked to see if there are other places in the file where a similar error could occur.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WW-2254) Stringlength validator xhtml template
should be locale independent
Posted by "Max Pimm (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/WW-2254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Max Pimm updated WW-2254:
-------------------------
Description:
The freemarker template that generates client side validation for the xhtml theme (template/xhtml/form-close-validate.ftl) generates the javascript functions for different validators.
In the case of the stringlength validator there are a series of lines of code that are generated that may not work in locales that are not English. For example, if you define the maxLength to be 1000.
value.length > ${validator.maxLength}
in a Spanish locale outputs
value.length > 1,000
Which results in a string comparison rather than a number comparison.
The solution that i've found is to force the formatting of maxLength and minLength in freemarker using ?string("#"). For example
${validator.maxLength?string("#")
I believe that all references to maxLength and minLength in form-close-validate.ft should use this. I haven't looked to see if there are other places in the file where a similar error could ocur.
was:
The freemarker template that generates client side validation for the xhtml theme (template/xhtml/form-close-validate.ftl) generates the javascript functions for different validators.
In the case of the stringlength validator there are a series of lines of code that are generated that may not work in locales that are not English. For example, if you define the maxLength to be 1000.
value.length > ${validator.maxLength}
in a Spanish locale outputs
value.length > 1,000
Which results in a string comparison rather than a number comparison.
To remedy this i have found two valid solutions.
1) Include number formating for freemarker: ${validator.maxLength?string("#")
2) Add javascript conversion to an int: parseInt(${validator.maxLength)
I have not tested either of these solutions in other browsers.
> Stringlength validator xhtml template should be locale independent
> ------------------------------------------------------------------
>
> Key: WW-2254
> URL: https://issues.apache.org/struts/browse/WW-2254
> Project: Struts 2
> Issue Type: Bug
> Components: Views
> Affects Versions: 2.0.9
> Environment: Firefox 2
> Reporter: Max Pimm
> Priority: Minor
>
> The freemarker template that generates client side validation for the xhtml theme (template/xhtml/form-close-validate.ftl) generates the javascript functions for different validators.
> In the case of the stringlength validator there are a series of lines of code that are generated that may not work in locales that are not English. For example, if you define the maxLength to be 1000.
> value.length > ${validator.maxLength}
> in a Spanish locale outputs
> value.length > 1,000
> Which results in a string comparison rather than a number comparison.
> The solution that i've found is to force the formatting of maxLength and minLength in freemarker using ?string("#"). For example
> ${validator.maxLength?string("#")
> I believe that all references to maxLength and minLength in form-close-validate.ft should use this. I haven't looked to see if there are other places in the file where a similar error could ocur.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WW-2254) Stringlength validator xhtml template
should be locale independent
Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/WW-2254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43187#action_43187 ]
Wes Wannemacher commented on WW-2254:
-------------------------------------
A better approach would be to use the freemarker built-in c, as documented here -
http://freemarker.org/docs/ref_builtins_number.html#ref_builtin_c. So it should look like ${validator.maxLength?c}. If/when I get a chance I'll look through the freemarker files for instances where this is appropriate.
> Stringlength validator xhtml template should be locale independent
> ------------------------------------------------------------------
>
> Key: WW-2254
> URL: https://issues.apache.org/struts/browse/WW-2254
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Tags
> Affects Versions: 2.0.9
> Environment: Firefox 2
> Reporter: Max Pimm
> Priority: Minor
> Fix For: 2.1.1
>
>
> The freemarker template that generates client side validation for the xhtml theme (template/xhtml/form-close-validate.ftl) generates the javascript functions for different validators.
> In the case of the stringlength validator there are a series of lines of code that are generated that may not work in locales that are not English. For example, if you define the maxLength to be 1000.
> value.length > ${validator.maxLength}
> in a Spanish locale outputs
> value.length > 1,000
> Which results in a string comparison rather than a number comparison.
> The solution that i've found is to force the formatting of maxLength and minLength in freemarker using ?string("#"). For example
> value.length > ${validator.maxLength?string("#")
> Which outputs the correct version.
> value.length > 1000
> I believe that all references to maxLength and minLength in form-close-validate.ft should use this. I haven't looked to see if there are other places in the file where a similar error could occur.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WW-2254) Stringlength validator xhtml template
should be locale independent
Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/WW-2254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Wes Wannemacher resolved WW-2254.
---------------------------------
Resolution: Fixed
Assignee: Wes Wannemacher
The only instance where the change was necessary was the one you mentioned. In other locations in the same file, the 'c' built-in was already being used.
> Stringlength validator xhtml template should be locale independent
> ------------------------------------------------------------------
>
> Key: WW-2254
> URL: https://issues.apache.org/struts/browse/WW-2254
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Tags
> Affects Versions: 2.0.9
> Environment: Firefox 2
> Reporter: Max Pimm
> Assignee: Wes Wannemacher
> Priority: Minor
> Fix For: 2.1.1
>
>
> The freemarker template that generates client side validation for the xhtml theme (template/xhtml/form-close-validate.ftl) generates the javascript functions for different validators.
> In the case of the stringlength validator there are a series of lines of code that are generated that may not work in locales that are not English. For example, if you define the maxLength to be 1000.
> value.length > ${validator.maxLength}
> in a Spanish locale outputs
> value.length > 1,000
> Which results in a string comparison rather than a number comparison.
> The solution that i've found is to force the formatting of maxLength and minLength in freemarker using ?string("#"). For example
> value.length > ${validator.maxLength?string("#")
> Which outputs the correct version.
> value.length > 1000
> I believe that all references to maxLength and minLength in form-close-validate.ft should use this. I haven't looked to see if there are other places in the file where a similar error could occur.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.