Commits

plightbo  committed e307973

ok, propertytag should have the same access that SD does now.

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

  • Participants
  • Parent commits 3789835

Comments (0)

Files changed (3)

File src/java/com/opensymphony/webwork/dispatcher/CoolUriServletDispatcher.java

 import java.util.HashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
+import java.io.IOException;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
             log.warn(e);
         }
 
-        serviceAction(request, response, "", actionName, parameters, getSessionMap(request), getApplicationMap());
+        try {
+            request = wrapRequest(request);
+            serviceAction(request, response, "", actionName, parameters, getSessionMap(request), getApplicationMap());
+        } catch (IOException e) {
+            String message = "Could not wrap servlet request with MultipartRequestWrapper!";
+            log.error(message, e);
+            sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, new ServletException(message, e));
+        }
     }
 }

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

     public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException {
 
 		try {
+            request = wrapRequest(request);
 	        serviceAction(request, response, getNameSpace(request), getActionName(request), getParameterMap(request), getSessionMap(request), getApplicationMap());
 		} catch (IOException e) {
 			String message = "Could not wrap servlet request with MultipartRequestWrapper!";
  */
     public void serviceAction(HttpServletRequest request, HttpServletResponse response, String namespace, String actionName, Map parameterMap, Map sessionMap, Map applicationMap) {
 
+        HashMap extraContext = createContextMap(parameterMap, sessionMap, applicationMap, request, response, getServletConfig());
+        extraContext.put(SERLVET_DISPATCHER, this);
+
+        try {
+            ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, actionName, extraContext);
+            request.setAttribute("webwork.valueStack", proxy.getInvocation().getStack());
+            proxy.execute();
+        } catch (ConfigurationException e) {
+            log.error("Could not find action", e);
+            sendError(request, response, HttpServletResponse.SC_NOT_FOUND, e);
+        } catch (Exception e) {
+            log.error("Could not execute action", e);
+            sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
+        }
+    }
+
+    public static HashMap createContextMap(Map parameterMap, Map sessionMap, Map applicationMap, 
+                                           HttpServletRequest request, HttpServletResponse response,
+                                           ServletConfig servletConfig) {
         HashMap extraContext = new HashMap();
         extraContext.put(ActionContext.PARAMETERS, parameterMap);
         extraContext.put(ActionContext.SESSION, sessionMap);
 
         extraContext.put(HTTP_REQUEST, request);
         extraContext.put(HTTP_RESPONSE, response);
-        extraContext.put(SERVLET_CONFIG, getServletConfig());
+        extraContext.put(SERVLET_CONFIG, servletConfig);
         extraContext.put(COMPONENT_MANAGER, request.getAttribute("DefaultComponentManager"));
-        extraContext.put(SERLVET_DISPATCHER, this);
 
         // helpers to get access to request/session/application scope
         extraContext.put("request", parameterMap);
         extraContext.put("application", applicationMap);
         extraContext.put("parameters", parameterMap);
 
-        try {
-            ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, actionName, extraContext);
-            request.setAttribute("webwork.valueStack", proxy.getInvocation().getStack());
-            proxy.execute();
-        } catch (ConfigurationException e) {
-            log.error("Could not find action", e);
-            sendError(request, response, HttpServletResponse.SC_NOT_FOUND, e);
-        } catch (Exception e) {
-            log.error("Could not execute action", e);
-            sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
-        }
+        return extraContext;
     }
 
     /**
     }
 
     protected Map getParameterMap(HttpServletRequest request) throws IOException {
-		request = wrapRequest(request);
         return request.getParameterMap();
     }
 
  * @param request
  * @return wrapped request or original request
  */
-    private HttpServletRequest wrapRequest(HttpServletRequest request) throws IOException {
+    protected HttpServletRequest wrapRequest(HttpServletRequest request) throws IOException {
         // don't wrap more than once
         if (request instanceof MultiPartRequestWrapper) {
             return request;

File src/java/com/opensymphony/webwork/views/jsp/PropertyTag.java

 import com.opensymphony.xwork.ActionContext;
 import com.opensymphony.xwork.util.OgnlValueStack;
 import com.opensymphony.util.TextUtils;
+import com.opensymphony.webwork.dispatcher.ServletDispatcher;
+import com.opensymphony.webwork.dispatcher.SessionMap;
+import com.opensymphony.webwork.dispatcher.ApplicationMap;
+import com.opensymphony.webwork.ServletActionContext;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import java.io.IOException;
+import java.util.Map;
 
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.TagSupport;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 
 /**
         OgnlValueStack stack = ActionContext.getContext().getValueStack();
 
         try {
-            if ((stack != null) && (stack.size() > 0)) {
-                Object actualValue = null;
+            if (stack == null)
+            {
+                stack = new OgnlValueStack();
+                HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
+                HttpServletResponse res = (HttpServletResponse) pageContext.getResponse();
+                Map extraContext = ServletDispatcher.createContextMap(req.getParameterMap(),
+                        new SessionMap(req.getSession()),
+                        new ApplicationMap(pageContext.getServletContext()),
+                        req,
+                        res,
+                        pageContext.getServletConfig());
+                extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext);
+                stack.getContext().putAll(extraContext);
+            }
+
+            Object actualValue = null;
 
-                if (value == null) {
-                    value = "that";
-                }
+            if (value == null) {
+                value = "that";
+            }
 
-                actualValue = stack.findValue(value, String.class);
+            actualValue = stack.findValue(value, String.class);
 
-                if (actualValue != null) {
-                    pageContext.getOut().print(prepare(actualValue));
-                } else if (defaultValue != null) {
-                    pageContext.getOut().print(prepare(defaultValue));
-                }
+            if (actualValue != null) {
+                pageContext.getOut().print(prepare(actualValue));
             } else if (defaultValue != null) {
                 pageContext.getOut().print(prepare(defaultValue));
             }