Multiple Key Value Pair Maps in Grails -
i'm trying dynamically populate map based off list of objects in grails. let's have of sort...
def criteria = object.createcriteria() def listresults = criteria.list() { -- query statements -- } def objmap = [:] each(object in listresults) { -- assign object property , object id map -- }
so i'm looking id, property pair entry in map. like:
[id:1, name:'name']
i need list of such pairs. how this? in advanced!!!
based on comment above wanting info object holding illustration carname , carid:
... listresults has result of criteria query def results = listresults.collect { r -> [carname: r.name, carid: r.id] }
will give list of objects results[0].carname = name of first car...
see http://groovy.codehaus.org/collections more groovy collection fun.
grails map
No comments:
Post a Comment