Reputation: 3428
Is it possible to pass 'params' in a redirect at the end of a Webflow? Basically the purpose of this variable or param passing from controller to controller is this, I want to have a variable or ${param.xyz} available on the view page only if the flow has been completed.
class Example1Controller{
def startFlow = {
begin {
....
}
....
....
finished {
action {
flash.message = 'success'
}
redirect(controller: 'example2', action: 'myaccount', params: [author: "Stephen King"])
}
}
}
OTHER CONTROLLER
class Example2Controller{
def myaccount() {
def here = $params.author
return [me:here]
}
}
GSP VIEW
<html>
<body>
<g:if test="${params.me}">
<p>This is what I want to display: **${me}**</p>
<p>But it must come from the first controller, from the flow.</p>
</g:if>
</body>
</html>
Basically the purpose of all this variable passing from controller to controller is this. I want to have a variable or ${param.} available on the view page only if the flow has been completed.
Upvotes: 0
Views: 3519
Reputation: 580
If I remember right, we did this before but we used the flow scope/ flow variables. Something like:
def myFlow = {
fin {
redirect: (controller: "xxx", action: "yyy", params: [someValue: flow.someValue])
}
}
Then, in the receiving end, something like:
def yyy = {
[ aaa: params.someValue ]
}
Upvotes: 1
Reputation: 125
You can use hiddenField .
<g:hiddenField name="myField" value="myValue" />
you can pass value from Example1Controller to Example1Gsp(as hideenField) and from that GSP you can get value in your Example2Controller.
Upvotes: 1