how to use method in another controller

Supposing I have a controller for books called BookController and a controller for authors called AuthorController and I want to remove a certain book when changing some author data:

In AuthorController :
// if some logic condition is met
BookController bookController = new BookController() = …
Normally the AuthorController.delete method will redirect you to some view and you normally don’t want that – the redirection should be done by BookController. In this case you can send a parameter to the controller and use it there to skip the redirection:
In AuthorController :
BookController bookController = new BookController() = …
bookController.params.doNotRedirect = ‘true’
In BookController.delete:
flash.message = …
redirect(action: “show”, id:
This entry was posted in Grails. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s