I have a command object in another package from my controller. I import it in the controller. I create and return an instance of this command from the create action:
def create = {
def reportCreateCommand = new ReportCreateCommand()
reportCreateCommand.name = params.name
reportCreateCommand.jrxmlFile = params.jrxmlFile
return [cmd: reportCreateCommand]
}
But the save action closure doesn't instantiate an object of this command from the properties:
def save = { ReportCreateCommand cmd ->
if (cmd.validate()){
def reportInstance = cmd.createReport()
reportInstance.save()
redirect(action:"show", id:reportInstance.id)
}
else {
render(view:"create", model:[cmd:cmd])
}
}
Apparently cmd is null in the save closure. The command class has two properties name and jrxmlFile. From what I know grails should instantiate the command object in the save method from the params. Do I have to do anything else?