2

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?

David Tinker
  • 9,383
  • 9
  • 66
  • 98

2 Answers2

2

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

aldrin
  • 4,482
  • 1
  • 33
  • 50
-1

Once you've done whatever you need to in your new controller, simply redirect to the original. Something along the lines of:

class NewController
 def doSomethingOriginal = {
    redirect(controller: "scaffoldedcontroller", action: "list", params: params)
 }
}

Hopefully this helps

raven
  • 435
  • 6
  • 17