Pivot
  1. Pivot
  2. PIVOT-681

TableRowEditor demo: amount field doesn't validate in some countries

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.1
    • Component/s: demos
    • Labels:
      None
    1. tableroweditor-demo.patch
      3 kB
      Dirk Möbius
    2. test-applet.html
      2 kB
      Dirk Möbius

      Activity

      Hide
      Sandro Martini added a comment -

      Just committed the fix, thank you very much Dirk.

      Note that in my commit I've also fixed the case of empty value in the Amount column (to avoid an NPE).

      Sandro

      Show
      Sandro Martini added a comment - Just committed the fix, thank you very much Dirk. Note that in my commit I've also fixed the case of empty value in the Amount column (to avoid an NPE). Sandro
      Hide
      Sandro Martini added a comment -

      Note that probably another related thing is this (summary):

      double click on a row:

      • pressing Escape is Good
      • while pressing click on another row (or pressing Enter) I get this:

      java.lang.NumberFormatException: For input string: "1286,90"
      at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
      at java.lang.Float.valueOf(Unknown Source)
      at org.apache.pivot.demos.roweditor.AmountBindMapping.valueOf(AmountBindMapping.java:33)
      at org.apache.pivot.wtk.TextInput.store(TextInput.java:841)
      at org.apache.pivot.wtk.Container.store(Container.java:613)
      at org.apache.pivot.wtk.content.TableViewRowEditor.endEdit(TableViewRowEditor.java:254)
      at org.apache.pivot.wtk.content.TableViewRowEditor$1.mouseDown(TableViewRowEditor.java:96)
      at org.apache.pivot.wtk.Container$ContainerMouseListenerList.mouseDown(Container.java:84)
      at org.apache.pivot.wtk.Container.mouseDown(Container.java:702)
      at org.apache.pivot.wtk.ApplicationContext$DisplayHost.processMouseEvent(ApplicationContext.java:840)
      at java.awt.Component.processEvent(Unknown Source)
      at org.apache.pivot.wtk.ApplicationContext$DisplayHost.processEvent(ApplicationContext.java:709)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)

      and I continue to get this exception until I exit from row editing mode

      My locale is Italian so these formats are not good in my locale, so maybe a simple catch of this in this demo could be enough ... just to avoid the exception.

      If in edit mode I write the right (locale-dependent decimal separators, or "." for decimals and "," for thousands), all is good and then the value is transformed and shown in the right locale-independent format of this Demo.
      Or better, "." become "," one time shown, and this is ok.
      But I'm unable to write "," for thousands in text fields, but maybe this could be due to some validation rule here, right ?

      Full thread here:
      http://apache-pivot-developers.417237.n3.nabble.com/Tests-on-td2132533.html

      Show
      Sandro Martini added a comment - Note that probably another related thing is this (summary): double click on a row: pressing Escape is Good while pressing click on another row (or pressing Enter) I get this: java.lang.NumberFormatException: For input string: "1286,90" at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source) at java.lang.Float.valueOf(Unknown Source) at org.apache.pivot.demos.roweditor.AmountBindMapping.valueOf(AmountBindMapping.java:33) at org.apache.pivot.wtk.TextInput.store(TextInput.java:841) at org.apache.pivot.wtk.Container.store(Container.java:613) at org.apache.pivot.wtk.content.TableViewRowEditor.endEdit(TableViewRowEditor.java:254) at org.apache.pivot.wtk.content.TableViewRowEditor$1.mouseDown(TableViewRowEditor.java:96) at org.apache.pivot.wtk.Container$ContainerMouseListenerList.mouseDown(Container.java:84) at org.apache.pivot.wtk.Container.mouseDown(Container.java:702) at org.apache.pivot.wtk.ApplicationContext$DisplayHost.processMouseEvent(ApplicationContext.java:840) at java.awt.Component.processEvent(Unknown Source) at org.apache.pivot.wtk.ApplicationContext$DisplayHost.processEvent(ApplicationContext.java:709) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) and I continue to get this exception until I exit from row editing mode My locale is Italian so these formats are not good in my locale, so maybe a simple catch of this in this demo could be enough ... just to avoid the exception. If in edit mode I write the right (locale-dependent decimal separators, or "." for decimals and "," for thousands), all is good and then the value is transformed and shown in the right locale-independent format of this Demo. Or better, "." become "," one time shown, and this is ok. But I'm unable to write "," for thousands in text fields, but maybe this could be due to some validation rule here, right ? Full thread here: http://apache-pivot-developers.417237.n3.nabble.com/Tests-on-td2132533.html
      Hide
      Greg Brown added a comment -

      We're about to start the release process for 2.0, so I'm just bumping this to 2.0.1.

      Show
      Greg Brown added a comment - We're about to start the release process for 2.0, so I'm just bumping this to 2.0.1.
      Hide
      Dirk Möbius added a comment - - edited

      I tested it now using the attached html page (file urls only, no http – hopefully this doesn't make any difference!).

      It seems to work. I tried some different region/language settings in the Windows system properties dialog, and it all worked accordingly. The cool thing is that if you use \u00AF as currency symbol, the decimal thousands separator also changes in some countries. For instance, in the Swiss locale (de_CH) it changes from "12,000" to "12'000".

      Show
      Dirk Möbius added a comment - - edited I tested it now using the attached html page (file urls only, no http – hopefully this doesn't make any difference!). It seems to work. I tried some different region/language settings in the Windows system properties dialog, and it all worked accordingly. The cool thing is that if you use \u00AF as currency symbol, the decimal thousands separator also changes in some countries. For instance, in the Swiss locale (de_CH) it changes from "12,000" to "12'000".
      Hide
      Greg Brown added a comment -

      Make sure you test this in an applet - we have had problems using the currency code in the past (it displayed the right character when run as a desktop app but not in the browser).

      Show
      Greg Brown added a comment - Make sure you test this in an applet - we have had problems using the currency code in the past (it displayed the right character when run as a desktop app but not in the browser).
      Hide
      Dirk Möbius added a comment -

      Attached file solves the i18n issues.

      Note that I replaced the currency symbol '$' with '\u00AF' which, according to the DecimalFormat javadocs, represents the currency symbol of the current user country. Tested with locales en_US, en_GB (pound), de_DE (€), it_IT (€), de_CH (Swiss, SFr.), zh_CN (Yen, font issues; Verdana).

      Show
      Dirk Möbius added a comment - Attached file solves the i18n issues. Note that I replaced the currency symbol '$' with '\u00AF' which, according to the DecimalFormat javadocs, represents the currency symbol of the current user country. Tested with locales en_US, en_GB (pound), de_DE (€), it_IT (€), de_CH (Swiss, SFr.), zh_CN (Yen, font issues; Verdana).

        People

        • Assignee:
          Sandro Martini
          Reporter:
          Dirk Möbius
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved:

            Development