Creating new Velocity context for web fragments
As we have mentioned in the previous recipes, it is possible to add Velocity variables while constructing a JIRA web fragment. JIRA supports a list of variables by default, which includes user
, req
, baseurl
, and so on. The full list and the details of these variables can be found at https://developer.atlassian.com/display/JIRADEV/Velocity+Contexts.
In this recipe, we will see how to add more variables to the Velocity context with the use of the context-provider
element.
How to do it...
The context-provider
element adds to the Velocity context available to the web section and web item modules. Only one context-provider
element can be added for an item. The following steps show how we can make use of a context provider:
Create the new
ContextProvider
class.The class must implement
com.atlassian.plugin.web.ContextProvider
. To make things easy, it is enough to extend theAbstractJiraContextProvider
class and override the following abstract method...