org.apache.struts2.components
Class ActionComponent

java.lang.Object
  extended by org.apache.struts2.components.Component
      extended by org.apache.struts2.components.ActionComponent

public class ActionComponent
extends Component

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.

 
 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";
        }
 }
 
 
 
   
      ....
     
         success.jsp
     
      
         success.jsp
     
      ....
   
 
 
 
  
The following action tag will execute result and include it in this page


The following action tag will do the same as above, but invokes method specialMethod in action


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


Field Summary
protected  boolean executeResult
           
protected  boolean ignoreContextParams
           
protected  java.lang.String name
           
protected  java.lang.String namespace
           
protected  com.opensymphony.xwork2.ActionProxy proxy
           
protected  javax.servlet.http.HttpServletRequest req
           
protected  javax.servlet.http.HttpServletResponse res
           
 
Fields inherited from class org.apache.struts2.components.Component
COMPONENT_STACK, id, parameters, stack
 
Constructor Summary
ActionComponent(com.opensymphony.xwork2.util.OgnlValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 
Method Summary
 boolean end(java.io.Writer writer, java.lang.String body)
          Callback for the end tag of this component.
 com.opensymphony.xwork2.ActionProxy getProxy()
           
 void setExecuteResult(boolean executeResult)
          whether the result of this action (probably a view) should be executed/rendered
 void setId(java.lang.String id)
          the id (if speficied) to put the action under stack's context.
 void setIgnoreContextParams(boolean ignoreContextParams)
          whether the request parameters are to be included when the action is invoked
 void setName(java.lang.String name)
          name of the action to be executed (without the extension suffix eg.
 void setNamespace(java.lang.String namespace)
          namespace for action to call
 
Methods inherited from class org.apache.struts2.components.Component
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, start, toString, usesBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

res

protected javax.servlet.http.HttpServletResponse res

req

protected javax.servlet.http.HttpServletRequest req

proxy

protected com.opensymphony.xwork2.ActionProxy proxy

name

protected java.lang.String name

namespace

protected java.lang.String namespace

executeResult

protected boolean executeResult

ignoreContextParams

protected boolean ignoreContextParams
Constructor Detail

ActionComponent

public ActionComponent(com.opensymphony.xwork2.util.OgnlValueStack stack,
                       javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse res)
Method Detail

end

public boolean end(java.io.Writer writer,
                   java.lang.String body)
Description copied from class: Component
Callback for the end tag of this component. Should the body be evaluated again?

NOTE: will pop component stack.

Overrides:
end in class Component
Parameters:
writer - the output writer.
body - the rendered body.
Returns:
true if the body should be evaluated again

getProxy

public com.opensymphony.xwork2.ActionProxy getProxy()

setId

public void setId(java.lang.String id)
the id (if speficied) to put the action under stack's context.

Overrides:
setId in class Component

setName

public void setName(java.lang.String name)
name of the action to be executed (without the extension suffix eg. .action)


setNamespace

public void setNamespace(java.lang.String namespace)
namespace for action to call


setExecuteResult

public void setExecuteResult(boolean executeResult)
whether the result of this action (probably a view) should be executed/rendered


setIgnoreContextParams

public void setIgnoreContextParams(boolean ignoreContextParams)
whether the request parameters are to be included when the action is invoked



Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.