This page last changed on Feb 23, 2010 by bspeakmon.
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 |
|
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 |
|
The identifier of the plugin module. This key must be unique within the plugin where it is defined.
Sometimes, in other contexts, you may need to uniquely identify a module. Do this with the complete module key. A module with key fred in a plugin with key com.example.modules will have a complete key of com.example.modules:fred. 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. |
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 |
|
Specifies WebWork 1 <action>s to define. Must contain at least one <action> element. |
<action> Element Attributes
Name |
Required |
Description |
name |
|
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 |
|
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. |
<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:
<webwork1 key="qquserissue" name="Quick Create User Issue" class="java.lang.Object">
<actions>
<action name="com.atlassian.jira.toolkit.action.QuickCreateUserIssueAction" alias="QuickCreateUserIssue">
<view name="createuserissue">/templates/quickcreateuser.vm</view>
</action>
</actions>
</webwork1>
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):
<webwork1 key="ASFAdministrators" name="Lists project leads on administrators page" class="java.lang.Object">
<actions>
<action name="org.apache.jira.plugins.actions.ASFAdministrators" alias="Administrators">
<view name="success">/templates/asf_administrators.vm</view>
</action>
</actions>
</webwork1>
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! 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. |
 | 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.
|