Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-4066

TextFieldDefinition with "Double" or "Decimal" type should not round input values

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 5.5.1
    • 5.4.7
    • forms
    • Saigon 73
    • 5

    Description

      Vaadin applies StringToDoubleConverter by default for Double properties.
      This converter internally uses a default NumberFormat instance with maximumFractionDigits set to 3.

      When applying the new value back on the server-side, Vaadin's AbstractTextField does this thing of beauty:

      T doubleConvertedFieldValue = convertFromModel(convertToModel(newFieldValue))

      This immediately updates the presentation to however this value would be rendered at a later point. I haven't dug yet why the approximated presentation value bubbles back to the model though.
      Even then, our forms are rightfully immediate, so we don't want to show a rounded value when user blurs the field (locale-dependent formatting still welcome).

      Proposal

      I suggest we bridge the gap and override StringToDoubleConverter#getFormat() and #setMaximumFractionDigits() to whatever more meaningful, then assign it automatically from the TextFieldFactory when property type is Double.


      Original report

      I use magnolia 5.4.7 and try to define a filed with type Double or Decimal in my app to save google maps coordinates in yaml:

      - name: latitude
        class: info.magnolia.ui.form.field.definition.TextFieldDefinition
        type: Double
      

      the app does work, but I only can keep 3 digital after point no matter what I enter. For example, I entere "10.123456789", after the field lost focus, it will be show as 10.123. Even it displayed as "10.123456789" after save and check the value again it saved as 10.123. How I can save all digital as double?

      via Magnolia forums: TextFieldDefinition with type "Double" or "Decimal" only can keep 3 digitals after point

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                oanh.thai Oanh Thai Hoang
                mgeljic Mikaël Geljić
                Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD

                    Time Tracking

                      Estimated:
                      Original Estimate - 3d
                      3d
                      Remaining:
                      Remaining Estimate - 0d
                      0d
                      Logged:
                      Time Spent - 3d
                      3d