Documentation for Confluence 2.5.4 - 2.5.8.
Documentation for [Confluence Cloud] and the latest Confluence Server is available too.

XWork plugin modules are available in Confluence 1.4 and later.

XWork plugin modules enable you to deploy XWork / WebWork 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 of more XWork package elements.

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

<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.
  • beneath this element, multiple package elements can be specified. These are standard XWork package elements, just as you would specify in xwork.xml.

Writing an Action

For information on how to write a WebWork action, please consult the WebWork documentation.

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 http://yourserver/confluence/plugins/livesearch/livesearch.action.

注意

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

  • Your packages should almost always extend the default Confluence package. It is useful to be aware of what this provides to you in the way of interceptors and result types.
  • You can give your packages any namespace you like, but we recommend using /plugins/unique/value - that is prefixing plugin packages with /plugins and then adding a string globally unique to your plugin. The only name you can't use is servlet as the /plugins/servlet URL pattern is reserved for Servlet plugins.
  • Views must be bundled in the JAR file in order to be used by your actions. This almost always means using Velocity views.
  • It is useful to be aware of the actions and features already bundled with Confluence, for example your actions will all be auto-wired by Spring (see Accessing Confluence Components From Plugin Modules) and your actions can use useful interfaces like PageAware and SpaceAware to reduce the amount of work they need to do.

The LiveSearch example is a neat example of an Ajax-style Confluence plugin which uses a bundled XWork module to do it's work:

Find this example in the /plugins/macros/livesearch directory within your Confluence distribution.

  • ラベルなし