Simo
Simo

Reputation: 828

Redirect to controller to another with param in grails

I have to redirect to a controller action called step2 when I get an error

this is the controller

 def step2(Example exampleInstance) {
     some code
 }

and this is where I catch the error

if (errorProp) {              
    redirect(????)
    return
}

how can I redirect to the controller and pass the exampleInstance too? I tried with t(uri: "/spot/step2") but I have not been able to pass the exampleInstance to step2. I also tried (action:'step2'.....) but I can't pass exampleInstance this way either. How can I handle this?

Upvotes: 1

Views: 296

Answers (1)

Joshua Moore
Joshua Moore

Reputation: 24776

You may have better luck using the chain method on the controller. This way you can pass the model along to the next action.

chain(action: 'step2', model: [exampleInstance: exampleInstance])

Upvotes: 3

Related Questions