0
votes

I've a controller and some actions within. Am i able to call these actions as methods from another controller as if i would call this action with post params?

I'm using the grails paypal plugin and it has an action called "buy". I don't want the user to POST the product-data and information to the buy-action. I already know the things the user wants to buy and i want to call the buy-action within my Controller as i would call a normal method and then i want to redirect the user to paypal (to the url, the buy action returns).

I'm using grails 2.0 and newest paypal plugin.

3

3 Answers

1
votes

No you cannot. You can tell from action A to chain to action B. But this is not calling it as a method, this will redirect the call to action B, you will not be anymore in action A's scope.

Maybe you can implement your action in a service. Then you can call it as you like from your controller's action

1
votes

As per my knowledge, You can redirect your action to another action which belongs to other controller.

you can use redirect method for that.

"redirect(controller: 'abc', action: 'actionName', params: 'params')"
0
votes

You may want to use chain(...).

Chain:

Uses flash storage to implicitly retain the model following an HTTP redirect from one action to another.