Skip to end of metadata
Go to start of metadata

Purpose of this Module Type

A webwork plugin module defines a URL-addressible 'action', allowing JIRA's user-visible functionality to be extended or partially overridden.

Configuration

The root element for the WebWork plugin module is webwork1. It allows the following attributes and child elements for configuration:

Attributes

Name

Required

Description

Default

class

(tick)

The class which implements this plugin module. The class you need to provide depends on the module type. For example, Confluence theme, layout and colour-scheme modules can use classes already provided in Confluence. So you can write a theme-plugin without any Java code. But for macro and listener modules you need to write your own implementing class and include it in your plugin. See the plugin framework guide to creating plugin module instances. The Java class of the module. For this module, it's fine to use Object, as the real brains are in the action classes below.

 

key

(tick)

The unique identifier of the plugin module. You refer to this key to use the resource from other contexts in your plugin, such as from the plugin Java code or JavaScript resources.

<component-import key="appProps" interface="com.atlassian.sal.api.ApplicationProperties"/>

In the example, appProps is the key for this particular module declaration, for component-import, in this case. I.e. the identifier for this module.

N/A

i18n-name-key

 

The localisation key for the human-readable name of the plugin module.

 

name

 

The human-readable name of the plugin module. I.e. the human-readable name of this module.

The plugin key.

roles-required The roles-required attribute can be used to only allow access to certain web actions to users which have been granted certain permissions. See Notes for more information. 

Elements

Name

Required

Description

description

 

A human-readable description of this WebWork module. May be specified as the value of this element for plain text or with the key attribute to use the value of a key from the i18n system.

actions

(tick)

Specifies WebWork 1 <action>s to define. Must contain at least one <action> element.

<action> Element Attributes

Name

Required

Description

name

(tick)

Full name of the class that implements the WebWork action. Actions in JIRA must extend the class com.atlassian.jira.action.JiraActionSupport. The class must not live in a package that JIRA has already reserved; authors should avoid the com.atlassian namespace altogether.

alias

(tick)

The path from which this action may be invoked in JIRA. For example, an action with alias MyNewJiraAction would be invoked by the URL http://<my-jira-server>/secure/MyNewJiraAction.jspa.

roles-required The roles-required attribute can be used to only allow access to certain web actions to users which have been granted certain permissions. See Notes for more information.

<action> Element Elements

Name

Required

Description

view

 

Directs where to send the user when the action completes. The name attribute maps to the return value from the overridden action methods (see the WebWork documentation for more details; common values are error, input, and success). The element's value is the path to the renderable view that is sent to the user (see Notes for more information).

Example

Here is a sample webwork plugin module:

Webwork plugins effectively extend the actions defined in the JIRA WEB-INF/classes/actions.xml file. You should look there for examples of what is possible. There is also a Webwork Sample plugin that contains many other basic examples.

Overriding a JIRA action

By specifying as 'alias' the name of an existing action (in actions.xml), you can override default JIRA behaviour. For example, to override the Administrators.jspa action (the 'Contact Administrators' link at the bottom of every page):

Here, templates/asf_administrators.vm is a Velocity template provided by (and bundled inside of) the plugin. It will be rendered when the org.apache.jira.plugins.actions.ASFAdministrators action returns.

Use your own package for your action classes!

Icon

In the past, plugin authors could rely on a bit of magic: putting their action class in the package com.atlassian.jira.web.action was enough to have JIRA find it without specifying the fully qualified class name in <action name="">. This was never a good idea, and in a Plugins2 plugin, it will simply not work. Always create a separate package space for your code and stay out of the com.atlassian namespace.

Make sure your template names are unique!

Icon

Your views are placed in a common pool, and JIRA simply retrieves the first template that fully matches the path, so if there are two plugins with templates /templates/admin.vm then one of them will be hidden by the other.

Avoid complex inheritance!

Icon

You can override existing actions without worry, but you cannot override an already overridden action. JIRA's WebWork implementation isn't smart enough to resolve polymorphic action hierarchies.

Sample Code

Notes

  • Renderable Views: The value of <view> should be a Velocity template; in the above example, the template templates/quickcreateuser.vm lives in the plugin artifact under that path. JSP views cannot be used from inside plugins; they can be used if they are installed into the JIRA webapp, but this complicates installation, upgrading, and troubleshooting. Use Velocity if you can.

  • Roles Required: 

    The roles-required attribute can be used to only allow access to certain web actions to users which have been granted certain permissions. The permissions are the short names of com.atlassian.jira.security.Permissions based permissions, and will only work for global based permissions. The three that are most useful are "admin", "sysadmin", and "use".

    You can add a roles-required attribute to the parent webwork element, or to a child action element (or both!).

  • No labels

8 Comments

  1. "If you wish to use a jsp, you must add it into the webapps directory or with the JIRA itself."

    An example would be useful, since adding the jsp file to webapps directory and then referring to it as "/myjsp.jsp" in the view element doesn't work for me

    1. Another useful thing would be to show how to use i18n with a webwork plugin.

      1. Any while you're at it, an example of how to add more variables to the velocity context would be great.

        1. to add more variables to the velocity context, add public getXyyy() methods to corresponding the Action class

      2. completely agree with that ^^

        I have a plugin ( source : https://studio.plugins.atlassian.com/source/browse/JST ) . In this plugin I have an page for some administrative stuff.

        The action is located here : org.hakanai.jira.plugins.web.action.StatusColorAction
        I have some properties files in the resource folder in the same package (org.hakanai.jira.plugins.web.action.StatusColorAction.properties) and... it doesn't work...

        atlassian-plugin.xml :

        I really don't understand where I should write the property file(s) for i18n

  2. Hi I have some problems.I want to change "issue tracking" in Jira and i try to add some functions in "CreateWorklog" action.

    I've found how this need to do http://confluence.atlassian.com/display/JIRA/Webwork+plugin+module but it don't work.

    My "atlassian-plugin.xml" is:
    ...
    <webwork1 key="WorklogAction" name="create worklog" class="java.lang.Object">
    <actions>
    <action name="issue.ExCreateWorklog" alias="CreateWorklog">
    <view name="error">/secure/views/issue/logwork.jsp</view>
    <view name="input">/secure/views/issue/logwork.jsp</view>
    <view name="securitybreach">/secure/views/securitybreach.jsp</view>
    </action>
    ....
    by extending CreateWorklog class i want to add some functions.When i add my time in textfield in "logwork.jsp" and push commit i get an Exception:

    HTTP Status 404 - Could not execute action ExCreateWorklog:Action 'ExCreateWorklog' not found or could not be initialized: Class not found
    <small><small><pre>java.lang.IllegalArgumentException: Action 'ExCreateWorklog' not found or could not be initialized: Class not found at com.atlassian.jira.config.webwork.JiraActionFactory$JiraPluginActionFactory.getActionImpl(JiraActionFactory.java:295) at webwork.action.factory.ScriptActionFactoryProxy.getActionImpl(ScriptActionFactoryProxy.java:54) at webwork.action.factory.XMLActionFactoryProxy.getActionImpl(XMLActionFactoryProxy.java:54) at
    ....
    if anybody has some ideas please help with this.

    1. You can`t use jsp, only vm.

      There is line in JiraResourcedModuleDescriptor.java :

      final ResourceDescriptor resource = getResourceDescriptor(JiraWorkflowPluginConstants.RESOURCE_TYPE_VELOCITY, resourceName);

  3. Anonymous

    how to ref service bean used spring?