struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nil...@apache.org
Subject svn commit: r564120 - in /struts/struts2/trunk/plugins/portlet/src: main/java/org/apache/struts2/portlet/ main/java/org/apache/struts2/portlet/dispatcher/ main/java/org/apache/struts2/portlet/result/ test/java/org/apache/struts2/portlet/result/
Date Thu, 09 Aug 2007 07:14:52 GMT
Author: nilsga
Date: Thu Aug  9 00:14:51 2007
New Revision: 564120

URL: http://svn.apache.org/viewvc?view=rev&rev=564120
Log:
WW-2052 Put location from renderDirect action in session instead of render parameter

Modified:
    struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java
    struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java
    struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
    struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java

Modified: struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java?view=diff&rev=564120&r1=564119&r2=564120
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java
Thu Aug  9 00:14:51 2007
@@ -103,4 +103,14 @@
      * {@link org.apache.struts2.portlet.context.PortletActionContext}.
      */
     String DEFAULT_ACTION_FOR_MODE = "struts.portlet.defaultActionForMode";
+    
+    /**
+     * Key for request attribute indicating if the action has been reset. 
+     */
+    String ACTION_RESET = "struts.portlet.actionReset";
+    
+    /**
+     * Key for session attribute indicating the location of the render direct action.
+     */
+    String RENDER_DIRECT_LOCATION = "struts.portlet.renderDirectLocation";
 }

Modified: struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java?view=diff&rev=564120&r1=564119&r2=564120
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java
Thu Aug  9 00:14:51 2007
@@ -23,6 +23,10 @@
 import com.opensymphony.xwork2.Action;
 
 import java.io.Serializable;
+import java.util.Map;
+
+import org.apache.struts2.interceptor.SessionAware;
+import org.apache.struts2.portlet.PortletActionConstants;
 
 /**
  * When a portlet is targetted for an <code>event</code>, the portlet will receive
two
@@ -38,7 +42,7 @@
  * specifying this action and the location of the view, which then will be executed in the
  * following render request.
  */
-public class DirectRenderFromEventAction implements Action, Serializable {
+public class DirectRenderFromEventAction implements SessionAware, PortletActionConstants,
Action, Serializable {
 
     private static final long serialVersionUID = -1814807772308405785L;
 
@@ -54,15 +58,6 @@
     }
 
     /**
-     * Set the location of the view.
-     *
-     * @param location The location to set.
-     */
-    public void setLocation(String location) {
-        this.location = location;
-    }
-
-    /**
      * Always return success.
      *
      * @return SUCCESS
@@ -70,4 +65,8 @@
     public String execute() throws Exception {
         return SUCCESS;
     }
+
+	public void setSession(Map session) {
+		location = (String)session.get(RENDER_DIRECT_LOCATION);
+	}
 }

Modified: struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java?view=diff&rev=564120&r1=564119&r2=564120
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
Thu Aug  9 00:14:51 2007
@@ -21,6 +21,7 @@
 package org.apache.struts2.portlet.result;
 
 import java.io.IOException;
+import java.util.Map;
 import java.util.StringTokenizer;
 
 import javax.portlet.ActionResponse;
@@ -48,7 +49,7 @@
  * Result type that includes a JSP to render.
  *
  */
-public class PortletResult extends StrutsResultSupport {
+public class PortletResult extends StrutsResultSupport implements PortletActionConstants
{
 
     private static final long serialVersionUID = 434251393926178567L;
 
@@ -131,11 +132,12 @@
             // View is rendered with a view action...luckily...
             finalLocation = finalLocation.substring(0, finalLocation
                     .lastIndexOf("."));
-            res.setRenderParameter(PortletActionConstants.ACTION_PARAM, finalLocation);
+            res.setRenderParameter(ACTION_PARAM, finalLocation);
         } else {
             // View is rendered outside an action...uh oh...
-            res.setRenderParameter(PortletActionConstants.ACTION_PARAM, "renderDirect");
-            res.setRenderParameter("location", finalLocation);
+            res.setRenderParameter(ACTION_PARAM, "renderDirect");
+            Map sessionMap = invocation.getInvocationContext().getSession();
+            sessionMap.put(RENDER_DIRECT_LOCATION, finalLocation);
         }
         res.setRenderParameter(PortletActionConstants.MODE_PARAM, PortletActionContext
                 .getRequest().getPortletMode().toString());

Modified: struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java?view=diff&rev=564120&r1=564119&r2=564120
==============================================================================
--- struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
(original)
+++ struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
Thu Aug  9 00:14:51 2007
@@ -34,6 +34,7 @@
 
 import junit.textui.TestRunner;
 
+import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.portlet.PortletActionConstants;
 import org.jmock.Mock;
 import org.jmock.cglib.MockObjectTestCase;
@@ -46,7 +47,7 @@
  * PortletResultTest. Insert description.
  *
  */
-public class PortletResultTest extends MockObjectTestCase {
+public class PortletResultTest extends MockObjectTestCase implements PortletActionConstants
{
 
     Mock mockInvocation = null;
     Mock mockConfig = null;
@@ -148,17 +149,18 @@
 
         Constraint[] params = new Constraint[]{eq(PortletActionConstants.ACTION_PARAM), eq("renderDirect")};
         mockResponse.expects(once()).method("setRenderParameter").with(params);
-        params = new Constraint[]{eq("location"), eq("/WEB-INF/pages/testJsp.jsp")};
-        mockResponse.expects(once()).method("setRenderParameter").with(params);
         params = new Constraint[]{eq(PortletActionConstants.MODE_PARAM), eq(PortletMode.VIEW.toString())};
         mockResponse.expects(once()).method("setRenderParameter").with(params);
         mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
 
         ActionContext ctx = ActionContext.getContext();
 
+        Map session = new HashMap();
+        
         ctx.put(PortletActionConstants.REQUEST, mockRequest.proxy());
         ctx.put(PortletActionConstants.RESPONSE, mockResponse.proxy());
         ctx.put(PortletActionConstants.PHASE, PortletActionConstants.EVENT_PHASE);
+        ctx.put(ActionContext.SESSION, session);
 
         PortletResult result = new PortletResult();
         try {
@@ -168,6 +170,7 @@
             e.printStackTrace();
             fail("Error occured!");
         }
+        assertEquals("/WEB-INF/pages/testJsp.jsp", session.get(RENDER_DIRECT_LOCATION));
     }
 
     public void testDoExecute_event_locationHasQueryParams() {



Mime
View raw message