A while back, in Configuring Reference Data In Grails, I talked about declaring elements in resources.groovy that could then be used to populate drop-down boxes in GSPs (to give one example).
Today, I found out an alternative way of declaring things:
beans = {
xmlns util: "http://www.springframework.org/schema/util"
util.list(id: 'myList') {
value 'String 0'
(1..5).each { value "String $it" }
value 'String n'
}
util.map(id: 'myMap') {
entry key: 'k0', value: 'v0'
(1..5).each { entry key: "k$it", value: "v$it" }
entry key: 'kn', value: 'vn'
}
}
I was long used to doing this in ‘plain’ Spring but wasn’t sure that I could actually use the ‘util’ namespace stuff in Grails.
Thanks to SpringSource’s Jeff Brown for pointing out on grails-user how to do it.
