本文整理汇总了Java中com.opensymphony.xwork2.ActionInvocation.getStack方法的典型用法代码示例。如果您正苦于以下问题:Java ActionInvocation.getStack方法的具体用法?Java ActionInvocation.getStack怎么用?Java ActionInvocation.getStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.opensymphony.xwork2.ActionInvocation
的用法示例。
在下文中一共展示了ActionInvocation.getStack方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intercept
import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Object action = invocation.getAction();
if (action instanceof ModelDriven) {
ModelDriven modelDriven = (ModelDriven) action;
ValueStack stack = invocation.getStack();
Object model = modelDriven.getModel();
if (model != null) {
stack.push(model);
}
if (refreshModelBeforeResult) {
invocation.addPreResultListener(new RefreshModelBeforeResult(modelDriven, model));
}
}
return invocation.invoke();
}
示例2: execute
import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public void execute(ActionInvocation ai) throws Exception {
ServletActionContext.getResponse().setContentType("text/plain");
ServletActionContext.getResponse().setCharacterEncoding("utf-8");
PrintWriter responseStream = ServletActionContext.getResponse().getWriter();
ValueStack valueStack = ai.getStack();
String text = (String) valueStack.findValue("textResult");
responseStream.print(text);
responseStream.flush();
}
示例3: handleInvalidToken
import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
protected String handleInvalidToken(ActionInvocation invocation) throws Exception {
ActionContext ac = invocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse response = (HttpServletResponse) ac.get(ServletActionContext.HTTP_RESPONSE);
String tokenName = TokenHelper.getTokenName();
String token = TokenHelper.getToken(tokenName);
if ((tokenName != null) && (token != null)) {
Map params = ac.getParameters();
params.remove(tokenName);
params.remove(TokenHelper.TOKEN_NAME_FIELD);
String sessionTokenName = TokenHelper.buildTokenSessionAttributeName(tokenName);
ActionInvocation savedInvocation = InvocationSessionStore.loadInvocation(sessionTokenName, token);
if (savedInvocation != null) {
// set the valuestack to the request scope
ValueStack stack = savedInvocation.getStack();
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
ActionContext savedContext = savedInvocation.getInvocationContext();
savedContext.getContextMap().put(ServletActionContext.HTTP_REQUEST, request);
savedContext.getContextMap().put(ServletActionContext.HTTP_RESPONSE, response);
Result result = savedInvocation.getResult();
if ((result != null) && (savedInvocation.getProxy().getExecuteResult())) {
result.execute(savedInvocation);
}
// turn off execution of this invocations result
invocation.getProxy().setExecuteResult(false);
return savedInvocation.getResultCode();
}
}
return INVALID_TOKEN_CODE;
}
示例4: getOverrideExpr
import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
protected Object getOverrideExpr(ActionInvocation invocation, Object value) {
ValueStack stack = invocation.getStack();
try {
stack.push(value);
return escape(stack.findString("top"));
} finally {
stack.pop();
}
}
示例5: intercept
import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ValueStack stack = invocation.getStack();
CompoundRoot root = stack.getRoot();
if (shouldCopyStack(invocation, root)) {
copyStack(invocation, root);
}
return invocation.invoke();
}
示例6: beforeResult
import com.opensymphony.xwork2.ActionInvocation; //导入方法依赖的package包/类
public void beforeResult(ActionInvocation invocation, String resultCode) {
ValueStack stack = invocation.getStack();
CompoundRoot root = stack.getRoot();
boolean needsRefresh = true;
Object newModel = action.getModel();
// Check to see if the new model instance is already on the stack
for (Object item : root) {
if (item.equals(newModel)) {
needsRefresh = false;
break;
}
}
// Add the new model on the stack
if (needsRefresh) {
// Clear off the old model instance
if (originalModel != null) {
root.remove(originalModel);
}
if (newModel != null) {
stack.push(newModel);
}
}
}