Databases Reference
In-Depth Information
Packages are used to group actions, and your XWork module can have more
than one.
name
is the only required attribute and identifies the package.
extends
specifies if the package inherits behavior from other packages; in this case we use the
Confluence default. With
namespace
, you can define under which URL the actions
are available.
<action name="alpha"
class="com.example.action.AlphaConfigAction"
method="view">
The
action
element is the basic unit of work and defines an action, which in most
cases is a URL. The name attribute completes the URL, as the preceding action is
available at
/plugins/config/alpha.action
. An action always has a class, which
will extend
ConfluenceActionSupport
. With
method
, it is possible to specify the
method in the class responsible for this action.
<result name="success"type="velocity">
/templates/alpha-config-action.vm
</result>
The
result
element will map the result of an action to a template. In the preceding
example, the velocity template
alpha-config-action.vm
will be rendered if our
AlphaConfigAction
returns
success
.
The action class
Every action should have an implementation that extends the
ConfluenceActionSupport
class. Actions can use the same implementation
if that makes sense for your plugin.
Our
AlphaConfigAction
class should look something like this:
public class AlphaConfigAction extends ConfluenceActionSupport {
public String view() {
if (condition == true) return SUCCESS;
return ERROR;
}
public String getViewMessage() {
return "Don't forget a towel";
}
}