hgoz
hgoz

Reputation: 641

Grails command object data binding behaviour on different locales

Grails (1.3.7) data binding behaviour differs with locales. It is ok but not works for my case.

class XCommand{
    Double value 
    //this value comes from an external service which has no idea about locale so default as en_
    //also it is a hidden value, end user is unaware of it
}

If user has a different Locale than en, this value comes to the controller as a different wrong double value

What is the solution? A custom converter? or changing/restoring locale just around the method invocation?

Upvotes: 2

Views: 356

Answers (1)

Sudhir N
Sudhir N

Reputation: 4096

You can use FixedLocaleResolver and set the default locale

Try this (in resource.groovy)

localeResolver (FixedLocaleResolver, Locale.ENGLISH) {
  Locale.setDefault (Locale.ENGLISH)
}

It will set locale fixed to Locale.ENGLISH

Upvotes: 1

Related Questions