public class ActionComponent extends ContextBean
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"; } }
<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" />
Modifier and Type | Field and Description |
---|---|
protected ActionProxyFactory |
actionProxyFactory |
protected boolean |
executeResult |
protected boolean |
flush |
protected boolean |
ignoreContextParams |
protected String |
name |
protected String |
namespace |
protected ActionProxy |
proxy |
protected javax.servlet.http.HttpServletRequest |
req |
protected javax.servlet.http.HttpServletResponse |
res |
protected boolean |
rethrowException |
protected ValueStackFactory |
valueStackFactory |
var
actionMapper, COMPONENT_STACK, devMode, parameters, stack, standardAttributesMap, throwExceptionOnELFailure
Constructor and Description |
---|
ActionComponent(ValueStack stack,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res) |
Modifier and Type | Method and Description |
---|---|
protected Map |
createExtraContext() |
protected HttpParameters |
createParametersForContext()
Creates parameters map using parameters from the value stack and component parameters.
|
boolean |
end(Writer writer,
String body)
Callback for the end tag of this component.
|
protected void |
executeAction()
Execute the requested action.
|
ActionProxy |
getProxy() |
void |
setActionMapper(ActionMapper mapper) |
void |
setActionProxyFactory(ActionProxyFactory actionProxyFactory) |
void |
setExecuteResult(boolean executeResult) |
void |
setFlush(boolean flush) |
void |
setIgnoreContextParams(boolean ignoreContextParams) |
void |
setName(String name) |
void |
setNamespace(String namespace) |
void |
setRethrowException(boolean rethrowException) |
void |
setValueStackFactory(ValueStackFactory valueStackFactory) |
getVar, putInContext, setVar
addAllParameters, addParameter, altSyntax, completeExpressionIfAltSyntax, copyParams, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findStringIfAltSyntax, findValue, findValue, findValue, getComponentStack, getParameters, getStack, getStandardAttributes, isValidTagAttribute, popComponentStack, setDevMode, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpressionIfAltSyntax, toString, usesBody
protected javax.servlet.http.HttpServletResponse res
protected javax.servlet.http.HttpServletRequest req
protected ValueStackFactory valueStackFactory
protected ActionProxyFactory actionProxyFactory
protected ActionProxy proxy
protected String name
protected String namespace
protected boolean executeResult
protected boolean ignoreContextParams
protected boolean flush
protected boolean rethrowException
public ActionComponent(ValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
public void setActionProxyFactory(ActionProxyFactory actionProxyFactory)
actionProxyFactory
- the actionProxyFactory to setpublic void setValueStackFactory(ValueStackFactory valueStackFactory)
public void setActionMapper(ActionMapper mapper)
setActionMapper
in class Component
public boolean end(Writer writer, String body)
Component
protected Map createExtraContext()
protected HttpParameters createParametersForContext()
public ActionProxy getProxy()
protected void executeAction()
public void setName(String name)
public void setNamespace(String namespace)
public void setExecuteResult(boolean executeResult)
public void setIgnoreContextParams(boolean ignoreContextParams)
public void setFlush(boolean flush)
public void setRethrowException(boolean rethrowException)
Copyright © 2000–2020 Apache Software Foundation. All rights reserved.