Tapestry
  1. Tapestry
  2. TAPESTRY-633

Default behavior of NumberTranslator treats zeros asymmetrically.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.1.2
    • Component/s: Framework
    • Labels:
      None

      Description

      The default behavior of the NumberTranslator uses omitZero = true. I think that special treatment of zero values should not be the default behavior of NumberTranslator so that default behavior is entirely predicatable.
      Also, omitZero=true creates undesirably asymmetric behavior for processing zeros when you investigate a parse/format/parse cycle.
      If I enter a zero into a TextField that uses the NumberTranslator it gets parsed as a 0, when that 0 value is formatted for display, it will be formatted as "" even though it was entered and submitted as zero. Upon resubmitting this value, without and changes, the "" will be parsed as a null. This means that the parsed value can change even though the text value was never altered. I think this is bad and should not be the default behavior of NumberTranslator. I suggest defaulting omitZero to false. Also, it would make more sense that if omitZero were true, then empty text values should be parsed as 0's. This would create symmetric behavior even when omitZero is true.

        Activity

        Paul Ferraro created issue -
        Jesse Kuhnert made changes -
        Field Original Value New Value
        Assignee Jesse Kuhnert [ jkuhnert ]
        Jesse Kuhnert made changes -
        Fix Version/s 4.1.1 [ 12312021 ]
        Hide
        Jesse Kuhnert added a comment -

        Sounds good to me. Implemented as described.

        Show
        Jesse Kuhnert added a comment - Sounds good to me. Implemented as described.
        Jesse Kuhnert made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Kent Tong added a comment -

        The new NumberTranslator is unconditionally treating empty as 0 (see the code below). It should do that only if omitZero is true.

        protected Object getValueForEmptyInput()

        { return new Double(0); }
        Show
        Kent Tong added a comment - The new NumberTranslator is unconditionally treating empty as 0 (see the code below). It should do that only if omitZero is true. protected Object getValueForEmptyInput() { return new Double(0); }
        Kent Tong made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Fixed [ 1 ]
        Jesse Kuhnert made changes -
        Fix Version/s 4.1.2 [ 12312202 ]
        Fix Version/s 4.1.1 [ 12312021 ]
        Hide
        Jesse Kuhnert added a comment -

        Omitzero now correctly returns null.

        Show
        Jesse Kuhnert added a comment - Omitzero now correctly returns null.
        Jesse Kuhnert made changes -
        Resolution Fixed [ 1 ]
        Status Reopened [ 4 ] Resolved [ 5 ]
        Mark Thomas made changes -
        Workflow jira [ 12324797 ] Default workflow, editable Closed status [ 12569108 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12569108 ] jira [ 12590386 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        462d 15h 54m 1 Jesse Kuhnert 16/Dec/06 18:38
        Resolved Resolved Reopened Reopened
        7d 19h 30m 1 Kent Tong 24/Dec/06 14:08
        Reopened Reopened Resolved Resolved
        70d 3h 22m 1 Jesse Kuhnert 04/Mar/07 17:31

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Paul Ferraro
          • Votes:
            4 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development