grails - How to populate Cmd Object with subset of properties from Domain class? -
i developing webflow based workflow , during initialisation action trying populate set of command objects single domain class, each command object containing subset of fields available in domain class... there's lot of fields see..
what i'm struggling how populate 'properties' of each command object matching properties domain class.
has had experience , knows how accomplish ?
thanks
dave
you following:
class domain { string lastname string firstname int age } class command { string lastname int age } def domain = new domain(lastname:'last', firstname:'first', age:33) def command = new command() command.properties.findall{ !["metaclass","class"].contains(it.key)}.each { k,v -> command[k] = domain[k] } assert 33 == command.age assert 'last' == command.lastname
the problem .properties includes 'class' , 'metaclass'. setting these 2 bad idea, they're getting filtered out.
Comments
Post a Comment