Search code examples
grailsgrails-controller

How can I replace a scaffolded controller action and still call the original in Grails?


I need to 'override' a scaffolded action in a controller, do some stuff and then invoke the original. I would prefer to use the dynamically generated method and not have to cut and paste the code.

class AccountController {
    static scaffold = Account
    def list = {
        // do something
        // invoke "super.list" i.e. the dynamically generated scaffold
    }

Any ideas?


Solution

  • You could consider using an interceptor or a filter instead (why? much cleaner)

    Controller Interceptors http://grails.org/doc/latest/guide/6.%20The%20Web%20Layer.html#6.1.5

    Filters http://grails.org/doc/latest/guide/6.%20The%20Web%20Layer.html#6.6