Package org.apache.struts2.components
Class ActionComponent
java.lang.Object
org.apache.struts2.components.Component
org.apache.struts2.components.ContextBean
org.apache.struts2.components.ActionComponent
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.
- id (String) - the id (if specified) to put the action under stack's context.
- name* (String) - name of the action to be executed (without the extension suffix eg. .action)
- namespace (String) - default to the namespace where this action tag is invoked
- executeResult (Boolean) - default is false. Decides whether the result of this action is to be executed or not
- ignoreContextParams (Boolean) - default to false. Decides whether the request parameters are to be included when the action is invoked
 
 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";
  }
 }
 
 
 
 
   <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>
 
 
 The following action tag will execute result and include it in this page
<s:action name="actionTagAction" executeResult="true" />
The following action tag will do the same as above, but invokes method specialMethod in action
<s:action name="actionTagAction!specialMethod" executeResult="true" />
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 <s:action name="actionTagAction!default" executeResult="false" /> <s:property value="#attr.stringByAction" />
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected ActionProxyFactoryprotected booleanprotected booleanprotected booleanprotected Stringprotected Stringprotected ActionProxyprotected jakarta.servlet.http.HttpServletRequestprotected jakarta.servlet.http.HttpServletResponseprotected booleanprotected ValueStackFactoryFields inherited from class org.apache.struts2.components.ContextBeanvarFields inherited from class org.apache.struts2.components.ComponentactionMapper, attributes, COMPONENT_STACK, devMode, escapeHtmlBody, performClearTagStateForTagPoolingServers, stack, standardAttributesMap, throwExceptionOnELFailure
- 
Constructor SummaryConstructorsConstructorDescriptionActionComponent(ValueStack stack, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected HttpParametersCreatesHttpParametersusing parameters from the value stack and component attributes.booleanCallback for the end tag of this component.protected voidExecute the requested action.getProxy()voidsetActionProxyFactory(ActionProxyFactory actionProxyFactory) voidsetExecuteResult(boolean executeResult) voidsetFlush(boolean flush) voidsetIgnoreContextParams(boolean ignoreContextParams) voidvoidsetNamespace(String namespace) voidsetRethrowException(boolean rethrowException) voidsetValueStackFactory(ValueStackFactory valueStackFactory) Methods inherited from class org.apache.struts2.components.ContextBeangetVar, putInContext, setVarMethods inherited from class org.apache.struts2.components.ComponentaddAllAttributes, addParameter, completeExpression, copyAttributes, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getAttributes, getComponentStack, getNamespace, getPerformClearTagStateForTagPoolingServers, getStack, getStandardAttributes, isAcceptableExpression, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setEscapeHtmlBody, setNotExcludedAcceptedPatterns, setPerformClearTagStateForTagPoolingServers, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpression, toString, usesBody
- 
Field Details- 
resprotected jakarta.servlet.http.HttpServletResponse res
- 
reqprotected jakarta.servlet.http.HttpServletRequest req
- 
valueStackFactory
- 
actionProxyFactory
- 
proxy
- 
name
- 
namespace
- 
executeResultprotected boolean executeResult
- 
ignoreContextParamsprotected boolean ignoreContextParams
- 
flushprotected boolean flush
- 
rethrowExceptionprotected boolean rethrowException
 
- 
- 
Constructor Details- 
ActionComponentpublic ActionComponent(ValueStack stack, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) 
 
- 
- 
Method Details- 
setActionProxyFactory- Parameters:
- actionProxyFactory- the actionProxyFactory to set
 
- 
setValueStackFactory
- 
endDescription copied from class:ComponentCallback for the end tag of this component. Should the body be evaluated again?
 NOTE: will pop component stack.
- 
createExtraContext
- 
createParametersForContextCreatesHttpParametersusing parameters from the value stack and component attributes. Any non-String array values will be converted into a single-value String array.- Returns:
- Instance of HttpParameters
 
- 
getProxy
- 
executeActionprotected void executeAction()Execute the requested action. If no namespace is provided, we'll attempt to derive a namespace using buildNamespace(). The ActionProxy and the namespace will be saved into the instance variables proxy and namespace respectively.
- 
setName
- 
setNamespace
- 
setExecuteResultpublic void setExecuteResult(boolean executeResult) 
- 
setIgnoreContextParamspublic void setIgnoreContextParams(boolean ignoreContextParams) 
- 
setFlushpublic void setFlush(boolean flush) 
- 
setRethrowExceptionpublic void setRethrowException(boolean rethrowException) 
 
-