Webwork plugin module

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. This must be unique across all JIRA add-ons.

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. The simple name of the class must be unique across all JIRA add-ons. That is, if one add-on has an action class MyEditAction then no other add-on should have an action class MyEditAction. It is recommended that each add-on use a prefix to make their action classes unique.

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.

Use your own package for your action classes!

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!

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!

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!).

Powered by Confluence and Scroll Viewport