You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mr...@apache.org on 2008/06/17 12:14:26 UTC
svn commit: r668602 - in /struts/struts2/trunk/core/src:
main/java/org/apache/struts2/components/ActionComponent.java
test/java/org/apache/struts2/views/jsp/ActionTagTest.java
Author: mrdon
Date: Tue Jun 17 03:14:25 2008
New Revision: 668602
URL: http://svn.apache.org/viewvc?rev=668602&view=rev
Log:
Fixing action tag so it doesn't set wrong action invocation
WW-2611
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java?rev=668602&r1=668601&r2=668602&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java Tue Jun 17 03:14:25 2008
@@ -45,6 +45,7 @@
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.ActionProxyFactory;
+import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
@@ -279,6 +280,7 @@
// get the old value stack from the request
ValueStack stack = getStack();
// execute at this point, after params have been set
+ ActionInvocation inv = ActionContext.getContext().getActionInvocation();
try {
proxy = actionProxyFactory.createActionProxy(namespace, actionName, methodName, createExtraContext(), executeResult, true);
@@ -292,6 +294,9 @@
} finally {
// set the old stack back on the request
req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
+ if (inv != null) {
+ ActionContext.getContext().setActionInvocation(inv);
+ }
}
if ((getVar() != null) && (proxy != null)) {
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java?rev=668602&r1=668601&r2=668602&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java Tue Jun 17 03:14:25 2008
@@ -39,6 +39,7 @@
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
+import com.mockobjects.dynamic.Mock;
/**
@@ -147,6 +148,27 @@
assertNull(result); // result is never executed, hence never set into invocation
}
+ public void testExecuteButResetReturnSameInvocation() throws Exception {
+ Mock mockActionInv = new Mock(ActionInvocation.class);
+ ActionTag tag = new ActionTag();
+ tag.setPageContext(pageContext);
+ tag.setNamespace("");
+ tag.setName("testActionTagAction");
+ tag.setExecuteResult(true);
+ ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInv.proxy());
+
+ ActionInvocation oldInvocation = ActionContext.getContext().getActionInvocation();
+ assertNotNull(oldInvocation);
+
+ tag.doStartTag();
+
+ // tag clear components on doEndTag
+ ActionComponent component = (ActionComponent) tag.getComponent();
+
+ tag.doEndTag();
+ assertTrue(oldInvocation == ActionContext.getContext().getActionInvocation());
+ }
+
public void testIngoreContextParamsFalse() throws Exception {
ActionTag tag = new ActionTag();
tag.setPageContext(pageContext);