This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • action
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Next »

Please make sure you have read the Tag Syntax document and understand how tag attribute syntax works.

Description

This tag enables developers to call actions directly from a JSP page by specifying the action name and an optional namespace. The body content of the tag is used to render the results from the Action. Any result processor defined for this action in struts.xml will be ignored, unless the executeResult parameter is specified.

Parameters

Dynamic Attributes Allowed:

false
 

Name

Required

Default

Evaluated

Type

Description

executeResult false false false Boolean Whether the result of this action (probably a view) should be executed/rendered
flush false true false Boolean Whether the writer should be flush upon end of action component tag, default to true
ignoreContextParams false false false Boolean Whether the request parameters are to be included when the action is invoked
name true false String Name of the action to be executed (without the extension suffix eg. .action)
namespace false namespace from where tag is used false String Namespace for action to call
rethrowException false false false Boolean Whether an exception should be rethrown, if the target action throws an exception
var false false String Name used to reference the value pushed into the Value Stack

Examples

Error rendering macro 'code': Invalid value specified for parameter 'java.lang.NullPointerException'
public class ActionTagAction extends ActionSupport {

 public String execute() throws Exception {
     return "done";
 }

 public String doDefault() throws Exception {
     ServletActionContext.getRequest().setAttribute("stringByAction", "This is a String put in by the action's doDefault()");
     return "done";
 }
}
Error rendering macro 'code': Invalid value specified for parameter 'java.lang.NullPointerException'
<xwork>
   ....
  <action name="actionTagAction1" class="tmjee.testing.ActionTagAction">
      <result name="done">success.jsp</result>
  </action>
   <action name="actionTagAction2" class="tmjee.testing.ActionTagAction" method="default">
      <result name="done">success.jsp</result>
  </action>
   ....
</xwork>
Error rendering macro 'code': Invalid value specified for parameter 'java.lang.NullPointerException'
<span>The following action tag will execute result and include it in this page</span>
<br>
<s:action name="actionTagAction" executeResult="true" />
<br>
<span>The following action tag will do the same as above, but invokes method specialMethod in action</span>
<br>
<s:action name="actionTagAction!specialMethod" executeResult="true" />
<br>
<span>The following action tag will not execute result, but put a String in request scope
     under an id "stringByAction" which will be retrieved using property tag</span>
<s:action name="actionTagAction!default" executeResult="false" />
<s:property value="#attr.stringByAction" />
  • No labels