i have a class
class Foo {
BigInteger phase
BigDecimal amount BigDecimal percent}
and want to use bindData to map some user input.
The user enters data in different formats for amount and percenti.e. :
- amount : 100.000,00
- percent : 75,50%
bindData parses this to
- amount = 100000 (in GERMAN Locale)
- percent : 75.5
is there any way to force grails to format domain-fields using different formats? For the example i would use NumberFormat.getNumberInstance for amount and NumberFormat.getPercentInstance for percent using the current Locale....
I tried the CustomEditor thing, but this procedure is type-bound 开发者_运维技巧and will not work on two different formats using the same type...
Anybody any idea? ;)
Thanks, Alex
Using a CustomEditor should work. You just pass a custom date binder that can determine the value being submitted and transform it. In our app for example, we have a custom date binder that transforms a single date field (normally Grails expects the date split into three fields).
精彩评论