Commits

Anonymous committed e08b938

WW-677: better solution to ww-677 based on what Simone Bordet provided which solves this for the ww:include tag as well as jsp:include

Also cleaned up some now-unnecessary code in ActionTag which is handled by creating a new copy of the value stack instead.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@620573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (4)

src/java/com/opensymphony/webwork/dispatcher/ServletDispatcher.java

 import com.opensymphony.xwork.interceptor.component.ComponentInterceptor;
 import com.opensymphony.xwork.interceptor.component.ComponentManager;
 import com.opensymphony.xwork.util.LocalizedTextUtil;
+import com.opensymphony.xwork.util.OgnlValueStack;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
         HashMap extraContext = createContextMap(requestMap, parameterMap, sessionMap, applicationMap, request, response, getServletConfig());
         extraContext.put(SERVLET_DISPATCHER, this);
 
+        // If there was a previous value stack, then create a new copy and pass it in to be used by the new Action
+        OgnlValueStack stack = (OgnlValueStack) request.getAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY);
+        if (stack != null) {
+            extraContext.put(ActionContext.VALUE_STACK,new OgnlValueStack(stack));
+        }
         try {
             ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, actionName, extraContext);
             request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, proxy.getInvocation().getStack());
             proxy.execute();
+            // If there was a previous value stack then set it back onto the request
+            if (stack != null){
+                request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY,stack);
+            }
         } catch (ConfigurationException e) {
             log.error("Could not find action", e);
             sendError(request, response, HttpServletResponse.SC_NOT_FOUND, e);

src/java/com/opensymphony/webwork/views/jsp/ActionTag.java

 
         // execute at this point, after params have been set
         try {
-            ActionContext actionContext = ActionContext.getContext();
-            OgnlValueStack stack = getStack();
-
-            Object top = null;
-
-            if ((stack != null) && (stack.size() > 0)) {
-                top = stack.peek();
-            }
-
             proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, actualName, createExtraContext(), executeResult);
             proxy.execute();
-
-            if (actionContext != null) {
-                if ((stack != null) && (stack.size() > 1)) {
-                    Object newTop = stack.peek();
-
-                    while ((newTop != null) && !newTop.equals(top)) {
-                        stack.pop();
-
-                        if (stack.size() == 0) {
-                            newTop = null;
-                        } else {
-                            newTop = stack.peek();
-                        }
-                    }
-                }
-            }
         } catch (Exception e) {
             log.error("Could not execute action: " + namespace + "/" + actualName, e);
         }

src/java/com/opensymphony/webwork/views/jsp/IncludeTag.java

 
 import com.opensymphony.webwork.config.Configuration;
 import com.opensymphony.webwork.util.FastByteArrayOutputStream;
-import com.opensymphony.webwork.ServletActionContext;
-import com.opensymphony.xwork.util.OgnlValueStack;
 import org.apache.commons.logging.LogFactory;
 
 import javax.servlet.RequestDispatcher;
     public int doEndTag() throws JspException {
         String page;
 
-        // Save the current value stack to set back into the request in case the include resets it
-        OgnlValueStack stack = getStack();
         // If value is set, we resolve it to get the page name
         if (valueAttr != null) {
             page = findString(valueAttr);
             LogFactory.getLog(getClass()).warn("Exception thrown during include of " + result, e);
             throw new JspTagException(e.toString());
         }
-        // Set the old value stack back into the request just in case it's been set by the include
-        pageContext.getRequest().setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY,stack);
 
         return EVAL_PAGE;
     }

src/webapp/includetagtest.jsp

 <ww:include page="included.action"/>
 <br>
 <jsp:include page="included.jsp" />
+<br>
+<jsp:include page="included.action"/>
+<br>
+<jsp:include page="included.jsp" />
+
 </body>
 </html>