Reputation: 137
Save parameters of a method to another.
Save parameters of the person in my def contentPerson
in my method saveperson
. Does anyone know how to save parameters - no found of my method savework
def saveperson(Person personIntance) {
def contentPerson =personInstance.save(flush:true)
redirect(controller:'Person', action:'creatework')
flash.message="I automatically select the person id";
}
def savework(Work workInstance,contentPerson) {
def work1 = new Work(name:params.name,person:contentPerson, profession:params.profession)
work1.save(flush:true)
}
Message:
No such property:
contentPerson
Upvotes: 1
Views: 2131
Reputation: 1218
redirect makes a completely new call, so it is a completely different context. you might want to try this:
redirect(controller:'Person', action:'creatework', params:[contentPerson: contentPerson])
or save it in flash, like this:
flash.contentPerson = contentPerson
you can use it for another request, like this:
flash.contentPerson
but you should avoid flash messages. so better pass parameters.
Upvotes: 2