Currently in my action method I unmarshal the request body and request params into two separate commands.
def someAction(BodyCommand bodyCmd) {
ParamsCommand paramsCmd = new ParamsCommand(params)
// Do something with bodyCmd and paramsCmd after
// validating both
if (bodyCmd.validate() && paramsCmd.validate()) {
...
}
}
I'd like to combine the commands and instead have just a single command.
def someAction(ActionCommand cmd) {
cmd.merge(params)
// Do something with cmd after validation
if (cmd.validate()) {
...
}
}
Is it possible to merge the params
into the request body command that's automatically unmarshalled by Grails?
Looks like Grails 2.5.0 does support a simple way to merge params into a domain class or command object.
cmd.properties = params