Talk:Building Plug-in using Grails

From ThemesWiki

Jump to: navigation, search

Hi - This is a really handy tutorial. Thanks for making the materials available !

I am pretty positive that the argument to getControllerClass should be the fully qualified package name, not the short name. I did an experiment with a simple plugin and wrote this code ->


 def doWithDynamicMethods = {ctx ->
   for(controller in application.controllerClasses) {
           println "found controller $controller.fullName"
   }
   GrailsClass  controllerClass
   controllerClass = application?.getControllerClass('TestSuppressionOfCacheHeaderEmissionForSomeActions')
   println "- 01: controller class using leaf name of class - is $controllerClass"
   controllerClass = application?.getControllerClass('testSuppressionOfCacheHeaderEmissionForSomeActions')
   println "- 02: controller class using leaf name of class (lower cased) - is $controllerClass"
   controllerClass = application?.getControllerClass('com.lackey.infra.TestSuppressionOfCacheHeaderEmissionForSomeActionsController')
   println "- 03: controller class using package qualified name of class - is $controllerClass"
   controllerClass = application?.getControllerClass('TestSuppressionOfCacheHeaderEmissionForSomeActionsController')
   println "- 03: controller class using just controller name - is $controllerClass"
 }

The output that I got appears below.. not that the only thing that succeeded in picking up the GrailsClass that wraps the controller class was alternative '03' in the code above.

found controller com.lackey.infra.NoSuppressionOfCacheHeaderEmissionDueToPropertyNotThereController

found controller com.lackey.infra.NoSuppressionOfCacheHeaderEmissionWhenPropertyPresentAndContainsRefsToNonExistentActionsController

found controller com.lackey.infra.TestSuppressionOfCacheHeaderEmissionForAllActions2Controller

found controller com.lackey.infra.TestSuppressionOfCacheHeaderEmissionForSomeActionsController

found controller com.BookController

- 01: controller class using leaf name of class - is null

- 02: controller class using leaf name of class (lower cased) - is null

- 03: controller class using package qualified name of class - is Artefact > TestSuppressionOfCacheHeaderEmissionForSomeActions

- 03: controller class using just controller name - is null


-chris

--

Chris Bedford

Founder & Lead Lackey
Build Lackey Labs
http://blog.buildlackey.com

</nowiki>

Personal tools