I have a Grails project where I use heavily customized scaffolding templates to add a beforeUpdate
template method to update
so that I can easily customize scaffolded Controller
's without having to generate and then edit each controller separately.
Unfortunately this doesn't work and only beforeUpdate
from scaffolding gets called.
I suspect it has to do with the code generation used by Groovy to inject the scaffolding code into the actual Controller
, but I can't find any confirmation.
What I'm asking is either a solution to the problem or an explanation for why it doesn't work.
Here is the scaffolding code:
def beforeUpdate = {
println "beforeUpdate from scaffold"
}
def update() {
// call before update hook
beforeUpdate()
def ${propertyName} = ${className}.get(params.id)
if (!${propertyName}) {
flash.message = message(code: 'default.not.found.message', args: [message(code: '${domainClass.propertyName}.label', default: '${className}'), params.id])
redirect(action: "list")
return
}
[...]
and the scaffolded controller code (which is not called, while I believe it should):
class CalendarController {
static scaffold = Calendar
def beforeUpdate = {
println "beforeUpdate from controller"
}
}
I have already tried grails clean ;-)
UPDATE
I have eventually realized that this is simply impossibile due to how the Grails scaffolding is designed. Closing.