struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [26/50] [abbrv] struts git commit: Migrates tiles-portlet to the same version
Date Fri, 15 Jul 2016 13:18:53 GMT
Migrates tiles-portlet to the same version


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f6d0e15f
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f6d0e15f
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f6d0e15f

Branch: refs/heads/master
Commit: f6d0e15f6b1a3a6fd0f9c46c00671d0aadf00a81
Parents: 0748886
Author: Lukasz Lenart <lukasz.lenart@gmail.com>
Authored: Tue Jan 12 10:36:46 2016 +0100
Committer: Lukasz Lenart <lukasz.lenart@gmail.com>
Committed: Tue Jan 19 16:19:18 2016 +0100

----------------------------------------------------------------------
 plugins/portlet-tiles/pom.xml                   |  2 +-
 .../struts2/views/tiles/PortletTilesResult.java | 50 +++++++++++++++-----
 pom.xml                                         |  5 +-
 3 files changed, 41 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/f6d0e15f/plugins/portlet-tiles/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml
index 9e9a81f..8b710b2 100644
--- a/plugins/portlet-tiles/pom.xml
+++ b/plugins/portlet-tiles/pom.xml
@@ -44,7 +44,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.tiles</groupId>
-            <artifactId>tiles-portlet</artifactId>
+            <artifactId>tiles-request-portlet</artifactId>
         </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>

http://git-wip-us.apache.org/repos/asf/struts/blob/f6d0e15f/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
----------------------------------------------------------------------
diff --git a/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
b/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
index 83fcd4e..f12274b 100644
--- a/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
+++ b/plugins/portlet-tiles/src/main/java/org/apache/struts2/views/tiles/PortletTilesResult.java
@@ -22,22 +22,20 @@
 package org.apache.struts2.views.tiles;
 
 import com.opensymphony.xwork2.ActionInvocation;
-import freemarker.template.TemplateException;
-import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.result.ServletDispatcherResult;
 import org.apache.struts2.portlet.PortletConstants;
 import org.apache.struts2.portlet.context.PortletActionContext;
+import org.apache.struts2.result.ServletDispatcherResult;
 import org.apache.tiles.TilesContainer;
 import org.apache.tiles.TilesException;
 import org.apache.tiles.access.TilesAccess;
-import org.apache.tiles.portlet.context.PortletUtil;
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.Request;
+import org.apache.tiles.request.portlet.RenderPortletRequest;
 
 import javax.portlet.ActionResponse;
-import javax.portlet.PortletException;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
+import javax.portlet.PortletContext;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
 import java.util.Map;
 
 /**
@@ -68,12 +66,15 @@ public class PortletTilesResult extends ServletDispatcherResult {
     protected void executeRenderResult(String location) throws TilesException {
         setLocation(location);
 
-        TilesContainer container = PortletUtil.getContainer(PortletActionContext.getPortletContext());
+        PortletContext portletContext = PortletActionContext.getPortletContext();
+        RenderRequest request = PortletActionContext.getRenderRequest();
+        RenderResponse response = PortletActionContext.getRenderResponse();
 
-        HttpServletRequest request = ServletActionContext.getRequest();
-        HttpServletResponse response = ServletActionContext.getResponse();
+        TilesContainer container = getCurrentContainer(request, portletContext);
+        ApplicationContext applicationContext = container.getApplicationContext();
+        Request currentRequest = new RenderPortletRequest(applicationContext, portletContext,
request, response);
 
-        container.render(location, request, response);
+        container.render(location, currentRequest);
     }
 
     protected void executeActionResult(String location, ActionInvocation invocation) {
@@ -87,4 +88,27 @@ public class PortletTilesResult extends ServletDispatcherResult {
         res.setRenderParameter(PortletConstants.MODE_PARAM, PortletActionContext.getRequest().getPortletMode().toString());
     }
 
+    protected TilesContainer getCurrentContainer(javax.portlet.PortletRequest request, PortletContext
context) {
+
+        TilesContainer container = (TilesContainer) request.getAttribute(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME);
+
+        if (container == null) {
+            container = getContainer(context);
+            request.setAttribute(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
+        }
+
+        return container;
+    }
+
+    protected TilesContainer getContainer(PortletContext context) {
+        return getContainer(context, TilesAccess.CONTAINER_ATTRIBUTE);
+    }
+
+    protected TilesContainer getContainer(PortletContext context, String key) {
+        if (key == null) {
+            key = TilesAccess.CONTAINER_ATTRIBUTE;
+        }
+        return (TilesContainer) context.getAttribute(key);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/f6d0e15f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3732ad1..1e0f708 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,6 +89,7 @@
         <asm.version>3.3</asm.version>
         <asm5.version>5.0.2</asm5.version>
         <tiles.version>3.0.5</tiles.version>
+        <tiles-request.version>1.0.6</tiles-request.version>
         <log4j2.version>2.5</log4j2.version>
 
         <!-- SCM Site Configuration -->
@@ -620,8 +621,8 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.tiles</groupId>
-                <artifactId>tiles-portlet</artifactId>
-                <version>${tiles.version}</version>
+                <artifactId>tiles-request-portlet</artifactId>
+                <version>${tiles-request.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.apache.tiles</groupId>


Mime
View raw message