GSP Variables - grails/grails-core GitHub Wiki

Challenge

At the moment, the global page scope of GSPs is 'polluted' with custom tag namespaces. For example, if you install the Bean Fields plugin at the time of writing, a bean variable is added to the page scope so that you can invoke tags as methods. Unfortunately, this means that you can no longer check whether there is a bean variable in the page model. Worse, code that checks for the existence of a bean variable will actually work until the Bean Fields plugin is installed.

Solutions

  1. Add an alternative mechanism for invoking tags as methods that doesn't add the custom namespaces to the page scope. For example, we could require all custom tags to be invoked with a g. prefix: g.bean.field(...).

  2. Page scope of GSPs is 'polluted' here: GroovyPage.java, Line 302 . We could replace the caching with a solution that doesn't use the page scope.