Actions are the basic "unit-of-work" in WebWork, they define, well, actions. An action will usually be a request, (and usually a button click, or form submit). The main action element (tag is too synonymous with JSP) has two parts, the friendly name (referenced in the URL, i.e. saveForm.action) and the corresponding "handler" class.
<action name="formTest" class="com.opensymphony.webwork.example.FormAction" method="processForm">
The optional "method" parameter tells WebWork which method to call based upon this action. If you leave the method parameter blank, WebWork will call the method execute() by default. If there is no execute() method and no method specified in the xml file, WebWork will throw an exception.
Also, you can tell WebWork to invoke "doSomething" method in your action by using the pattern "actionName!something" in your form. For example, "formTest!save.action" will invoke the method "save" in FormAction class. The method must be public and take no arguments:
public String save() throws Exception { ... return SUCCESS; }
All the configuration for "actionName" will be used for "actionName!something" (interceptors, result types, etc...)
Action Support
Action class attribute could be left out such as following
<action name="myAction"> .... </action>
In this case, the class will default to com.opensymphony.xwork.ActionSupport which have an execute() method that returns SUCCESS by default.
Default Action Reference
Since Webwork 2.2.1 you are also able to specify a default action to be executed when no other action is matched in the xwork.xml. This feature is provided mainly to eliminate the need to create an action class and/or element for very simple or similar results. The default action name can be set inside the package element like below:
<package name="myPackage" ....> ... <default-action-ref name="simpleViewResultAction"> <!-- An example of a default action that is just a simple class that has 3 fields: successUrl, errorUrl, and inputUrl. This action parses the request url to set the result values. In the normal case it just renders velocity results of the same name as the requested url. --> <action name="simpleViewResultAction" class="SimpleViewResultAction"> <result type="velocity">${successUrl}</result> <result name="error" type="velocity">${errorUrl}</result> <result name="input" type="velocity">${inputUrl}</result> </action> ... </package>
Caution
This feature should be configured such that there is only one default action per namespace. Therefore if you have multiple packages declaring a default action with the same namespace, it is not guaranteed which action will be the default.
Note
Note that the name attribute is left out for the first result, as WebWork will default to "success" if it is left out.
In this case any request to action not defined in this package will automatically trigger action with alias "simpleViewResultAction" to be executed.
Most of the content here provided by Matt Dowell <matt.dowell@notiva.com>