...
The action mapping can specify an interceptor stack, a set of result types, and a set of exception handlers. But, only the { name
attribute is required. (Everything else can also be provided at a global scope.)
Code Block | ||
---|---|---|
| ||
<action name="Hello" class="cookbook2.Hello"> <result>/pages/Hello/Result.jsp</result> <result name="input">/pages/Hello/Input.jsp</result> </action> |
...
In a web application, the name
attribute is matched a part of the location requested by a browser (or other HTTP client). The framework will drop the host and application name and the extension, and match what's in the middle. So, a request for http://www.planetstruts.org/action2-cookbook/HelloHome.do
will map to the Hello
Home
action.
Within an application, the link to an action is usually generated by a SAF tag. The tag can specify the action by name, and the framework will render the default extension and anything else that is needed.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<action name="delete" class="example.CrudAction" method="delete"> |
{!) If there is no
execute
method and no method specified in the configuration, the framework will throw an exception.
...
The ActionSupport class has {[
execute
}} and input
methods that return "success".
...
A good practice is to link to actions rather than pages. An effect of this strategy is that an action will fire before a page renders. Another common stategy is to first render a page using an alias, and then have it submit back to the default execute method. Using these strategies together creates an opporutnity opportunity to use a "post-back" form that doesn't specify an action. The form simply submits back to the action that created it.
...
Code Block | ||
---|---|---|
| ||
<action name="Hello" class="cookbook2.Hello"> <result>/pages/Hello/Result.jsp</result> <result name="input">/pages/Hello/Input.jsp</result> </action> |
Code Block | ||
---|---|---|
| ||
<saf:form method="POST"> <ww:textfield label="Please enter your name" name="name"/> <ww:submit/> </saf:form> |
...