Event Listener module
Job module
Language module
Macro Module
Theme module
Web UI modules
Workflow module
XWork-WebWork module

Rate this page:

XWork-WebWork module

Available:

Confluence 1.4 and later

XWork plugin modules enable you to deploy XWork / WebWork (now part of Apache Struts) actions and views as a part of your plugins.

The XWork Plugin Module

Each XWork module is deployed as a plugin module of type xwork and contains one or more XWork package elements.

Here is an example atlassian-plugin.xml file containing a single XWork module:

1
2
<atlassian-plugin name='List Search Macros' key='confluence.extra.livesearch'>
    ...

    <xwork name="livesearchaction" key="livesearchaction">
        <package name="livesearch" extends="default" namespace="/plugins/livesearch">
            <default-interceptor-ref name="defaultStack" />

            <action name="livesearch"
                class="com.atlassian.confluence.extra.livesearch.LiveSearchAction">
                <result name="success" type="velocity">/templates/extra/livesearch/livesearchaction.vm</result>
            </action>
        </package>
    </xwork>
</atlassian-plugin>
  • The xwork element has no class attribute.
  • You can specify multiple package elements within the xwork element. These are standard XWork package elements, just as you would specify in xwork.xml.
  • Ensure the <result> entry appears on a single line with no spaces.

Writing an Action

WebWork actions must implement com.opensymphony.xwork.Action. However, we recommend you make your action extend ConfluenceActionSupport, which provides a number of helper methods and components that are useful when writing an Action that works within Confluence.

Other action base-classes can be found within Confluence, but we recommend you don't use them - the hierarchy of action classes in Confluence is over-complicated, and likely to be simplified in the future in a way that will break your plugins.

Accessing Your Actions

Actions are added to the XWork core configuration within Confluence, which means they are accessed like any other action.

For example, given the above atlassian-plugin.xml, the livesearch action would be accessed at yourserver/confluence/plugins/livesearch/livesearch.action.

Creating a Velocity Template for Output

Your Velocity template must be specified with a leading slash (/) in the plugin XML configuration, and the path must correspond to the path inside the plugin JAR file.

In the above example, the Velocity template must be found in /templates/extra/livesearch/livesearchaction.vm inside the plugin JAR file. In the example plugin's source code, this would mean the Velocity template should be created in src/main/resources/template/extra/livesearch/.

Inside your Velocity template, you can use $action to refer to your action, and many other variables to access Confluence functionality. See Confluence Objects Accessible From Velocity for more information.

Notes

Some issues to be aware of when developing or configuring an XWork plugin:

Important Security Note

If you are writing an XWork plugin, it is very important that you read this security information: XWork Plugin Complex Parameters and Security.

See also

Rate this page: