Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3650

Double Value Conversion with requestLocale=de

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.3
    • Fix Version/s: 2.5.12
    • Labels:
      None
    • Environment:

      Tomcat 6/7, Windows 7

      Description

      When using the german locale, s:textbox (and supposedly also other tags) don't use localization for Double values. Effect: in a form that prints a double value to a s:textfield with value="doubleVarName", the double value of 1.0 is printed out while it should be 1,0 with german locale. If the same form is sent to an action, the params interceptor interprets the 1.0 somehow differently and stores 10.0 in the double field "doubleVarName".

      I don't find another hack for me other than forcing english locale, which is okay for my app but might not be okay for other developers. (My first bugreport, hope it's fine)

        Issue Links

          Activity

          Hide
          lukaszlenart Lukasz Lenart added a comment -

          I've started working on this and just noticed that this can break backward compatibility as I'm going to rewrite all the internals converters to based on LocaleProvider - it isn't a huge job rather I expect some problems with migration - users' hacks around this can blow up

          Show
          lukaszlenart Lukasz Lenart added a comment - I've started working on this and just noticed that this can break backward compatibility as I'm going to rewrite all the internals converters to based on LocaleProvider - it isn't a huge job rather I expect some problems with migration - users' hacks around this can blow up
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user lukaszlenart opened a pull request:

          https://github.com/apache/struts/pull/21

          Locale aware converters

          Basically this PR introduces new converters which are `Locale` aware - they will convert values based on current `Locale` provided by `LocaleProvider`

          This cover issues

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/apache/struts feature/locale-aware-converters

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/struts/pull/21.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #21


          commit dfb5203ea7010516ae7aa02889936392a982ab3a
          Author: Lukasz Lenart <lukaszlenart@apache.org>
          Date: 2014-08-14T08:39:13Z

          Defines new interface to implement specialized internal converters

          commit b195fb3af7d44409dccdb94e675c1a7ace99daab
          Author: Lukasz Lenart <lukaszlenart@apache.org>
          Date: 2014-08-14T08:39:35Z

          Adds new internal converter of Double to String

          commit fe329f50242b17f109d3e80c4213f012ce2d950a
          Author: Lukasz Lenart <lukaszlenart@apache.org>
          Date: 2014-08-14T08:39:52Z

          Uses the new internal converters and adds new test case


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user lukaszlenart opened a pull request: https://github.com/apache/struts/pull/21 Locale aware converters Basically this PR introduces new converters which are `Locale` aware - they will convert values based on current `Locale` provided by `LocaleProvider` This cover issues WW-3650 WW-3171 WW-3184 You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/struts feature/locale-aware-converters Alternatively you can review and apply these changes as the patch at: https://github.com/apache/struts/pull/21.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #21 commit dfb5203ea7010516ae7aa02889936392a982ab3a Author: Lukasz Lenart <lukaszlenart@apache.org> Date: 2014-08-14T08:39:13Z Defines new interface to implement specialized internal converters commit b195fb3af7d44409dccdb94e675c1a7ace99daab Author: Lukasz Lenart <lukaszlenart@apache.org> Date: 2014-08-14T08:39:35Z Adds new internal converter of Double to String commit fe329f50242b17f109d3e80c4213f012ce2d950a Author: Lukasz Lenart <lukaszlenart@apache.org> Date: 2014-08-14T08:39:52Z Uses the new internal converters and adds new test case
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          I introduced some changes but now I see some side effects like problem with rounding value:

          Expected :percentage must be between 0.1 and 10.1, current value is 100.0123.
          Actual   :percentage must be between 0.1 and 10.1, current value is 100.012.
          

          I think the best option is to leave current internal converters unchanged but add possibility to implement converters for primitives by user.

          Show
          lukaszlenart Lukasz Lenart added a comment - I introduced some changes but now I see some side effects like problem with rounding value: Expected :percentage must be between 0.1 and 10.1, current value is 100.0123. Actual :percentage must be between 0.1 and 10.1, current value is 100.012. I think the best option is to leave current internal converters unchanged but add possibility to implement converters for primitives by user.
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Just to leave a workaround - you can always implement your own StrutsTypeConverter and register it to be used for all Double values in xwork-conversion.properties

          java.lang.Double=com.myComp.myApp.MyDoubleConverter
          
          Show
          lukaszlenart Lukasz Lenart added a comment - Just to leave a workaround - you can always implement your own StrutsTypeConverter and register it to be used for all Double values in xwork-conversion.properties java.lang. Double =com.myComp.myApp.MyDoubleConverter
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/struts/pull/21

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/struts/pull/21
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 266d78d32c786276f37ae701267f6719ea9f8a75 in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=266d78d ]

          WW-3650 Supports double conversion for different locale

          Show
          jira-bot ASF subversion and git services added a comment - Commit 266d78d32c786276f37ae701267f6719ea9f8a75 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=266d78d ] WW-3650 Supports double conversion for different locale
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 2fb431d97e479881cace53d4dc387a961b52f575 in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=2fb431d ]

          WW-3171 WW-3650 WW-4581 makes number converters locale aware

          Show
          jira-bot ASF subversion and git services added a comment - Commit 2fb431d97e479881cace53d4dc387a961b52f575 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=2fb431d ] WW-3171 WW-3650 WW-4581 makes number converters locale aware
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          PR got merged

          Show
          lukaszlenart Lukasz Lenart added a comment - PR got merged
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Struts-JDK7-master #633 (See https://builds.apache.org/job/Struts-JDK7-master/633/)
          WW-3650 Supports double conversion for different locale (lukaszlenart: rev 266d78d32c786276f37ae701267f6719ea9f8a75)

          • (edit) core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java
          • (edit) core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java
          • (edit) core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #633 (See https://builds.apache.org/job/Struts-JDK7-master/633/ ) WW-3650 Supports double conversion for different locale (lukaszlenart: rev 266d78d32c786276f37ae701267f6719ea9f8a75) (edit) core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java (edit) core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java (edit) core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java

            People

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              ithoughts Tim Dellas
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development