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 http://confluence.atlassian.com/display/JIRADEV/Web+Fragments#WebFragments-VelocityContext.
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
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...