Plugins You can find out about all the publicly available Grails plugins.

Context param plugin

  • Tags: /
  • Latest: 1.0
  • Last Updated: 17 July 2012
  • Grails version: 1.3.7 > *
0 vote
compile "org.grails.plugins:context-param:1.0"

 Documentation  Source


Automatically adds parameters specified as @ContextParam on a controller to redirect calls.


grails install-plugin context-param


In some cases, you may want to ensure a specific context is always passed along to a Grails controllers. For example, you may want to make sure a RESTful url always includes a region for certain controllers. Your URLMappings.groovy will have an entry like:
This requires passing the region parameter through every request if you want avoid keeping that state in the session. In practice, this means that all of the redirect and chain blocks will have to repeat appending the same parameters to every call. Your code will have lines like these scattered all over:
redirect(action: show, params: [region: region])
chain(action: create, model: [cmd: cmd], params: [region: region])
This plugin allows you to annotate controllers with @ContextParam annotations to specify these parameters and automatically include them on any redirect or chain calls.

For example:

class InstanceController {
will append the region param from the current request if redirect(controller: 'instance') is called, eliminating the need to append the params to the call.

In addition, the configuration of context param declarations is available on the grailsApplication object in the field Map<String,List<String>> controllerNamesToContextParams. To check if region is a @ContextParam for a particular controller you can call:

This plugin will be used by Netflix's Asgard project for it's upgrade to Grails 2.1.