Question

Greetings! I have an intercept in controller like so:

    def beforeInterceptor = {

    if( session.sessionRoastId == null ){

        session.intendedController = params.controller
        session.intendedAction = params.action

        redirect( controller: 'roastId', action: 'enterRoastId' )
        return false
    }
}

... after the redirect business is taken care of, what's proper way to continue on to the original controller action and view that the intercept picked up?

Right now I'm putting the details in the session to be accessed later down the road, but is there a better way?

Thanks.

Was it helpful?

Solution

You can pass the original target URI as a parameter to the 'enterRoastId' action, and then redirect there.

def beforeInterceptor = {
    if( session.sessionRoastId == null ){
        redirect( controller: 'roastId', action: 'enterRoastId', params: [
            action: params.action, 
            controller: params.controller
        ])
        return false
    }
}

then in your action AFTER enterRoastId:

if (params.action && params.controller) {
    redirect(controller: params.controller, action: params.action)
    return false
}

If you don't want to expose the action/controller, then just pass the values to the 'enterRoastId' view, and pass them back via a hidden field.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top