groovy - Do I have to do something special for command objects to get instantiated in grails? -
groovy - Do I have to do something special for command objects to get instantiated in grails? -
i have command object in bundle controller. import in controller. create , homecoming instance of command create action:
def create = { def reportcreatecommand = new reportcreatecommand() reportcreatecommand.name = params.name reportcreatecommand.jrxmlfile = params.jrxmlfile homecoming [cmd: reportcreatecommand] }
but save action closure doesn't instantiate object of command 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 null in save closure. command class has 2 properties name , jrxmlfile. know grails should instantiate command object in save method params. have else?
i believe calling cmd.validate()
unnecessary, should phone call cmd.haserrors()
. command object validating default on creation of object
grails groovy
Comments
Post a Comment