I am trying to customize the HTML markup of the excellent FilterPane grails plugin, however I have some difficulties. FilterPane provides a bunch of tags to render the search / filter form, and I would like to override them in my application.
I thought I could just copy _tagName.gsp , which I would like to override from
plugins/filterpane-2.0.1.1/grails-app/views/filterpane
in
grails-app/views/filterpane
and modify them, however, it seems that Grails never checks if the application overrides the plugin's views if the render method is called with the specified property of the plugin name.
org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.findAndCacheTemplate contains private code in a private method:
... GroovyPageScriptSource scriptSource; if (pluginName == null) { scriptSource = groovyPageLocator.findTemplateInBinding(templatePath, pageScope); } else { scriptSource = groovyPageLocator.findTemplateInBinding(pluginName, templatePath, pageScope); } ...
therefore, when a non-zero pluginName , we just grab the plugin's view and never check if this application overrides.
I thought an easy way around this problem would be to simply override GrailsConventionGroovyPageLocator.findTemplateInBinding or some other similar method in GrailsConventionGroovyPageLocator , however, it seems impossible to do this from a Grails application or
I created a simple class that overrides GrailsConventionGroovyPageLocator , replacing the findTemplateInBinding method findTemplateInBinding the one that checks the application view directory before checking it. Then I changed resources.groovy by adding a doWithSpring closure to replace the default groovyPageLocator :
def doWithSpring = { def pageLocator = delegate.getBeanDefinition("groovyPageLocator") pageLocator.beanClass = MyConventionGroovyPageLocator }
However, this does not seem to trigger when my application starts.
I am really at a loss. I expected it to be simple, but it turned into a piece of worms. Anyone have any suggestions? All I want to do is to override the views provided by the plugin ...