[ 
https://issues.apache.org/jira/browse/TAP5-2409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14547865#comment-14547865
 ] 

Geoff Callender edited comment on TAP5-2409 at 5/18/15 11:03 AM:
-----------------------------------------------------------------

As an experiment, I created a translator to use with TextFields that have 
{{type="number"}}. In {{toClient(...)}} it formatted the number with "." for 
the decimal separator and no grouping separator, eg. {{12345.67}}. The browser 
displayed it correctly for the browser's locale, e.g. {{12.345,67}}. However, 
if I changed the Tapestry locale (e.g. put "en/" in the URL), it made no 
difference to the display. The browser doesn't know about the Tapestry locale.

Unless we can fix this then I'd say {{type="number"}} simply can't be used with 
switchable Tapestry locales.

For the record, the other part of my experiment was to modify 
{{validation.js}}: there are 2 calls to the parseNumber function. Before each 
one I inserted this:
{code}
        var isTypeNumber = $field.attr("type") == "number";
        if (isTypeNumber) {
          decimal = ".";
          grouping= "";
        }
{code}
and after each one I inserted this:
{code}
        if (isTypeNumber) {
                  decimal = messages("decimal-symbols.decimal");
                  grouping = messages("decimal-symbols.group");
        }
{code}
It worked like a charm.


was (Author: geoffcallender):
As an experiment, I created a translator to use with TextFields that have 
{{type="number"}}. In {{toClient(...)}} it formatted the number with "." for 
the decimal separator and no grouping separator, eg. {{12345.67}}. The browser 
displayed it correctly for the browser's locale, e.g. {{12.345,67}}. However, 
if I changed the Tapestry locale (e.g. put "en/" in the URL), it made no 
difference to the display. The browser doesn't know about the Tapestry locale.

Unless we can fix this then I'd say {{type="number"}} simply can't be used with 
switchable Tapestry locales.

For the record, the other part of my experiment was to modify validation.js: 
there are 2 calls to the parseNumber function. Before each one I inserted this:
{code}
        var isTypeNumber = $field.attr("type") == "number";
        if (isTypeNumber) {
          decimal = ".";
          grouping= "";
        }
{code}
and after each one I inserted this:
{code}
        if (isTypeNumber) {
                  decimal = messages("decimal-symbols.decimal");
                  grouping = messages("decimal-symbols.group");
        }
{code}
It worked like a charm.

> type="number" fails when decimal separator isn't "."
> ----------------------------------------------------
>
>                 Key: TAP5-2409
>                 URL: https://issues.apache.org/jira/browse/TAP5-2409
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.4
>            Reporter: Geoff Callender
>         Attachments: 
> 0001-TAP5-2409-add-a-test-for-validating-a-TextField-with.patch
>
>
> This probably affects versions before 5.4 too.
> I have BigDecimal fields that I'm editing with TextField. On mobile devices I 
> would like a numeric keyboard to pop up, so I added type="number".
> This all worked just fine in English, but then I switched locale to French 
> and found Tapestry's client-side validation rejecting it as not a number.
> Digging around, I found that with type="number", the W3C spec requires the 
> browser to translate the field value to a String with a "." decimal 
> separator. The problem for Tapestry is that Tapestry's validation always 
> expects the field value to be untouched and in the format of the locale. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to