Tapestry 5
  1. Tapestry 5
  2. TAP5-540

Allow exact parsing of numeric client input by creating a BigDecimal Translator and enabling parseBigDecimal in DecimalFormat

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0.1
    • Fix Version/s: 5.1.0.1
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      The current NumericTranslator is great but it is not easy to build on it since the classes are internal.

      Tapestry should provide a BigDecimal Translator which uses the infrastructure created for TAP5-211 but parses client input directly to BigDecimal retaining the full precision of that input.

      For example, I need a client input of 100.00 to be translated to a BigDecimal with value 100.00. Contributing a NumericTranslator<BigDecimal> results in a BigDecimal with value 100 because the input is parsed to a long by the NumberFormat before being type coerced.

        Activity

        Paudi Moriarty created issue -
        Hide
        Paudi Moriarty added a comment -

        Currently, I'm using a custom BigDecimal Translator which lacks the localisation features recently introduced. I would prefer not to have to use internal classes to add those features.

        Show
        Paudi Moriarty added a comment - Currently, I'm using a custom BigDecimal Translator which lacks the localisation features recently introduced. I would prefer not to have to use internal classes to add those features.
        Howard M. Lewis Ship made changes -
        Field Original Value New Value
        Assignee Howard M. Lewis Ship [ hlship ]
        Howard M. Lewis Ship made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Howard M. Lewis Ship added a comment -

        I'm struggling with generating a proper number of right-of-the-decimal digits. It looks like Java's default numberformatter uses three digits of precision. For BigDecimal, we should have infinite digits ... but then we're back to use toString() to parse.

        Show
        Howard M. Lewis Ship added a comment - I'm struggling with generating a proper number of right-of-the-decimal digits. It looks like Java's default numberformatter uses three digits of precision. For BigDecimal, we should have infinite digits ... but then we're back to use toString() to parse.
        Hide
        Thiago H. de Paula Figueiredo added a comment -

        Tip: BigDecimal.scale() retuns the number of digits to the right of the decimal point. Then use DecimalFormat.setMinimumFractionDigits() to define the number of digits to the right of the decimal point when formatting.

        Show
        Thiago H. de Paula Figueiredo added a comment - Tip: BigDecimal.scale() retuns the number of digits to the right of the decimal point. Then use DecimalFormat.setMinimumFractionDigits() to define the number of digits to the right of the decimal point when formatting.
        Howard M. Lewis Ship made changes -
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Closed [ 6 ]
        Fix Version/s 5.1.0.1 [ 12313660 ]

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Paudi Moriarty
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development