Rate this page:
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.
Each XWork module is deployed as a plugin module of type xwork and contains one or more XWork elements.
Here is an example file containing a single XWork module:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<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>
WebWork actions must implement . 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.
Actions are added to the XWork core configuration within Confluence, which means they are accessed like any other action.
For example, given the above , the action would be accessed at .
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 inside the plugin JAR file. In the example plugin's source code, this would mean the Velocity template should be created in .
Inside your Velocity template, you can use to refer to your action, and many other variables to access Confluence functionality. See Confluence Objects Accessible From Velocity for more information.
Some issues to be aware of when developing or configuring an XWork plugin:
All webwork modules mounted under will automatically be protected by secure administrator sessions. To opt out of this protection you can mark your class or webwork action method with the WebSudoNotRequired annotation. Conversely, all webwork actions mounted outside the namespace are not protected and can be opted in by adding the WebSudoRequired annotation.
Both of these annotations work on the class or the action method. If you mark a method with the annotation, only action invocations invoking that method will be affected by the annotations. If you annotate the class, any invocation to that class will be affected. Sub-classes inherit these annotations.
If you are writing an XWork plugin, it is very important that you read this security information: XWork Plugin Complex Parameters and Security.
Rate this page: