Grails
  1. Grails
  2. GRAILS-9895 Improve Data Binding
  3. GRAILS-5029

Command object containing doubles get processed incorrectly

    Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.1
    • Fix Version/s: None
    • Component/s: Controllers
    • Labels:
      None
    • Environment:
      Windows 7 / Intellij 8.1.3 / Grails 1.1.1 / Chrome (in Belgium)

      Description

      Consider...

      class DoubleCommand {
      double d
      }

      public class TestController {
      def home = { DoubleCommand d ->
      render "$

      {d.d}

      "
      }
      }

      apart from being pretty useless, this code produces following exciting result:

      http://localhost:8080/<project>/test/home/1?d=1.23456 => 1.23456 (as expected)
      http://localhost:8080/<project>/test/home/1?d=1.23456789 => 1.23456789E8 (hmm? that big?)
      http://localhost:8080/<project>/test/home/1?d=1,23456789 => 1.23456789 (the comma as a decimal sign seems to do the trick?)

        Activity

        Hide
        Wouter Hendrickx added a comment -

        Looking a bit deeper into the 1.1.1 source... It's probably a Locale / NumberFormat / CustomNumberEditor issue
        ref. src/web/org/codehaus/groovy/grails/web/binding/GrailsDataBinder.java

        Show
        Wouter Hendrickx added a comment - Looking a bit deeper into the 1.1.1 source... It's probably a Locale / NumberFormat / CustomNumberEditor issue ref. src/web/org/codehaus/groovy/grails/web/binding/GrailsDataBinder.java
        Hide
        Vito Andolini added a comment -

        This is a pretty serious bug and was reported in 1.1.1. I just discovered it in 1.3.7, too. Is there any plan to fix it?

        Show
        Vito Andolini added a comment - This is a pretty serious bug and was reported in 1.1.1. I just discovered it in 1.3.7, too. Is there any plan to fix it?
        Hide
        Jeff Scott Brown added a comment -

        I am attaching a 2.3.0.M1 app. Can you please verify that this looks like it is working for you?

        grails-app/controllers/com/demo/TestController.groovy
        package com.demo
        
        class TestController {
        
            def home(DoubleCommand d) {
                render "${d.d}"
            }
        }
        
        class DoubleCommand {
            double d
        }
        
        
        $ ./grailsw run-app
        | Server running. Browse to http://localhost:8080/doubleit
        
        $ curl http://localhost:8080/doubleit/test/home?d=1.23456789
        1.23456789
        
        Show
        Jeff Scott Brown added a comment - I am attaching a 2.3.0.M1 app. Can you please verify that this looks like it is working for you? grails-app/controllers/com/demo/TestController.groovy package com.demo class TestController { def home(DoubleCommand d) { render "${d.d}" } } class DoubleCommand { double d } $ ./grailsw run-app | Server running. Browse to http://localhost:8080/doubleit $ curl http://localhost:8080/doubleit/test/home?d=1.23456789 1.23456789

          People

          • Assignee:
            Jeff Scott Brown
            Reporter:
            Wouter Hendrickx
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Last Reviewed:

              Development