Tapestry
  1. Tapestry
  2. TAPESTRY-1071

Client-side number validation does not work

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.1.1
    • Fix Version/s: 4.1.2
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      any, german locale (not sure whether this matters), Snapshot from Aug 15th

      Description

      Specifiying no special pattern for the NumberTranslator leads to:

      • client calls dojo number validation with groupingChar=' and any number of decimal places
      • if you make dojo happy (eg. 1'234.0), validation fails on the server-side.

      If the reason for this is not a trivial omission which is easily fixed, I could investigate further ...

        Activity

        Hide
        Marcus Schulte added a comment -

        Should be a simple fix in NumberTranslator:

        The defaultFormat is "#", which is good.
        Then, in renderContribution, the grouping separator is always passed to dojo in the JSON object (line 134).

        I think, passing the grouping separator only if format.isGroupingUsed() returns true, should resolve the issue

        Thus, instead of

        + "separator:" + JSONObject.quote(format.getDecimalFormatSymbols().getGroupingSeparator())

        line 134 should probably read

        + ( format.isGroupingUsed ? "separator:" + JSONObject.quote(format.getDecimalFormatSymbols().getGroupingSeparator()) : "")

        So, it's a trivial buggy after all.

        Show
        Marcus Schulte added a comment - Should be a simple fix in NumberTranslator: The defaultFormat is "#", which is good. Then, in renderContribution, the grouping separator is always passed to dojo in the JSON object (line 134). I think, passing the grouping separator only if format.isGroupingUsed() returns true, should resolve the issue Thus, instead of + "separator:" + JSONObject.quote(format.getDecimalFormatSymbols().getGroupingSeparator()) line 134 should probably read + ( format.isGroupingUsed ? "separator:" + JSONObject.quote(format.getDecimalFormatSymbols().getGroupingSeparator()) : "") So, it's a trivial buggy after all.
        Hide
        Jesse Kuhnert added a comment -

        Fixed. Sorry about that. Should've been caught earlier.

        Show
        Jesse Kuhnert added a comment - Fixed. Sorry about that. Should've been caught earlier.
        Hide
        Gary Mak added a comment -

        Why has this fix been rolled back since Dec 10 2006? Now this error happens again for Tapestry 4.1.1 and 4.1.2-SNAPSHOT.

        Show
        Gary Mak added a comment - Why has this fix been rolled back since Dec 10 2006? Now this error happens again for Tapestry 4.1.1 and 4.1.2-SNAPSHOT.
        Hide
        Marcus Schulte added a comment -

        regression

        Show
        Marcus Schulte added a comment - regression
        Hide
        Jesse Kuhnert added a comment -

        Re-fixed as per Marcus's instructions. (thanks)

        Show
        Jesse Kuhnert added a comment - Re-fixed as per Marcus's instructions. (thanks)
        Hide
        Marcus Schulte added a comment -

        With the use of dojo.i18n.number.isReal, it is not sufficient anymore to just omit the grouping specs, they must be explicitly set to "no-grouping-values".
        Thus, NumberValidator needs
        ...
        String grouping;
        if (format.isGroupingUsed())

        { grouping = ",separator:" + JSONObject.quote(format.getDecimalFormatSymbols().getGroupingSeparator()); grouping += ",groupSize:" + format.getGroupingSize(); }

        else grouping = ",separator:'',groupSize:0";
        ...

        An equivalent fix needs to be made to the comparison-validators which call tapestry.form.validation.greaterThan/lessOrEqual.

        Show
        Marcus Schulte added a comment - With the use of dojo.i18n.number.isReal, it is not sufficient anymore to just omit the grouping specs, they must be explicitly set to "no-grouping-values". Thus, NumberValidator needs ... String grouping; if (format.isGroupingUsed()) { grouping = ",separator:" + JSONObject.quote(format.getDecimalFormatSymbols().getGroupingSeparator()); grouping += ",groupSize:" + format.getGroupingSize(); } else grouping = ",separator:'',groupSize:0"; ... An equivalent fix needs to be made to the comparison-validators which call tapestry.form.validation.greaterThan/lessOrEqual.
        Hide
        Jesse Kuhnert added a comment -

        I think I fixed this bug within the tapestry provided version of dojo itself because that's where it is. ...Using separator:"" should be enough but the built in regexp logic in dojo blows up because it doesn't take this into account....So either way it should work "as is" right now.....but I guess you can give it a go yourself when you get back

        Show
        Jesse Kuhnert added a comment - I think I fixed this bug within the tapestry provided version of dojo itself because that's where it is. ...Using separator:"" should be enough but the built in regexp logic in dojo blows up because it doesn't take this into account....So either way it should work "as is" right now.....but I guess you can give it a go yourself when you get back

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Marcus Schulte
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development