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?
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
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
精彩评论