|
Hi
I have a command object which has a List of Area domain objects. I can't get the binding to work correctly and wonder if this should work. Currently it tries to set add Strings to my List/Set. I'm using grails 1.3.6 Cheers, Micke --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
I think you'll need to create a custom property registrar for your Area domain.
Add these two classes to your src/groovy folder: class AreaEditor extends PropertyEditorSupport { void setAsText(String text) { value = Area.get(text) } } class AreaEditorRegistrar implements PropertyEditorRegistrar { void registerCustomEditors(PropertyEditorRegistry registry) { registry.registerCustomEditor(Area, new AreaEditor()) } } Add this line to the beans closure in conf/spring/resources.groovy: customPropertyEditorRegistrar(AreaEditorRegistrar) Now the Area domains should automatically bind do your command object. For example, with a command object like: class MyCommand { List<Area> areas } Your multiple-select should work if you format it like: <g:select name="areas" multiple="true" from="${Area.list()}" optionKey="id" value="${cmd?.areas}"/> -Dana
On Fri, Jan 28, 2011 at 12:01 PM, Mikael Andersson <[hidden email]> wrote: Hi |
|
Many thanks for that! Just tried it and it worked perfectly :)
Thanks again, Micke On 29 January 2011 02:51, Dana Berke <[hidden email]> wrote: > I think you'll need to create a custom property registrar for your Area > domain. > > Add these two classes to your src/groovy folder: > > class AreaEditor extends PropertyEditorSupport { > void setAsText(String text) { > value = Area.get(text) > } > } > > class AreaEditorRegistrar implements PropertyEditorRegistrar { > void registerCustomEditors(PropertyEditorRegistry registry) { > registry.registerCustomEditor(Area, new AreaEditor()) > } > } > > Add this line to the beans closure in conf/spring/resources.groovy: > > customPropertyEditorRegistrar(AreaEditorRegistrar) > > Now the Area domains should automatically bind do your command object. For > example, with a command object like: > > class MyCommand { > List<Area> areas > } > > Your multiple-select should work if you format it like: > > <g:select name="areas" multiple="true" from="${Area.list()}" optionKey="id" > value="${cmd?.areas}"/> > > -Dana > > On Fri, Jan 28, 2011 at 12:01 PM, Mikael Andersson <[hidden email]> > wrote: >> >> Hi >> >> I have a command object which has a List of Area domain objects. I >> can't get the binding to work correctly and wonder if this should >> work. Currently it tries to set add Strings to my List/Set. >> >> I'm using grails 1.3.6 >> >> Cheers, >> Micke >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
