ibaralf
ibaralf

Reputation: 12528

Grails: Dynamically call another action

Is it possible to call another controller-action with the name of the controller-action being passed as a parameter. Something like this:

View:

<g:createLink controller="book" action="list"
params="[id: '1', onCompleteController='nextCon', onCompleteAction='nextAct']"/>

Controller (Book):

def list = {
   ... //Do something like save book

   **execute onCompleteController/onCompleteAction**

   return render(text: [success:true] as JSON))

}

Upvotes: 2

Views: 4754

Answers (1)

Bagira
Bagira

Reputation: 2243

you can do that by using forward or redirect (which ever fits in your case).

Some thing like

redirect(controller:onCompleteController, action: onCompleteAction, model:[])

forward(controller:onCompleteController, action: onCompleteAction, params:[])

Upvotes: 5

Related Questions