I am using grails 2.0.1 and overriding render method.
i have the following code.
grailsApplication.controllerClasses.each { controller ->
//keep old render method
def original = controller.metaClass.getMetaMethod("render", [Map] as Class[])
controller.metaClass.originalRender = original.getClosure()
controller.metaClass.renderForBrand = { Map args ->
originalRender(args)
}
}
In original.getClosure() i got the below Error.
Message: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.reflection.CachedMethod.getClosure() is applicable for argument types: () values: []
Possible solutions: getClass()
Line | Method
->> 300 | evaluateEnvironmentSpecificBlock in grails.util.Environment
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 293 | executeForEnvironment in ''
| 269 | executeForCurrentEnvironment . . in ''
| 303 | innerRun in java.util.concurrent.FutureTask$Sync
| 138 | run . . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . . . . . . . . . . . . . in ''
^ 662 | run in java.lang.Thread
In grails 1.3.7 my code is working fine, In case of grails 2.x it fails.
Any help is greatly appriciated.
Thanks.
You might save a reference to the original
rendermethod and call theinvokemethod in order to execute it:This mechanism works regardless of using Grails 1.3.x or 2.0.x (I tested both).