views:

1830

answers:

2

In Grails, one can 'bindData' in controller:

Book b = new Book()
bindData(b, params)

What if I have a date field with specific format (e.g. yyyy-MM-dd) from user input? In Spring, we can use registerCustomEditor(). How about Grails?

+1  A: 

Have you already come across the Extended Data Binding Plugin?

From the documentation on the site, it appears to offer both aspects which you are referring to

  • Allow customization of the DataBinder that will be used to parse user-defined input and populate objects (typically domain objects) with custom PropertyEditors on both application-wide and controller-specific levels.as String.

  • Extend controllers with dynamic methods to allow data binding and bean wrapping.

j pimmel
Yes, I've already come across that. But I think it's a bit clumsy as you have to remember to do bind and wrapbean all the time. So I ask if anyone know a simpler method
jackysee
+1  A: 

With Grails 1.1.1, you can implement a PropertyEditorRegistrar and use that to specify a format. See http://www.nabble.com/Grails-1.1.1-change-in-binding-date-properties-td23546175.html

aldrin