From ddeb7f0f7cc2600ceb36b8532fc433861a38c20e Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 25 Nov 2015 20:37:42 +0100 Subject: [PATCH] Updates Portal Tiles integration (cherry picked from commit 6edc0ff) --- plugins/portlet-tiles/pom.xml | 4 +++ .../views/tiles/PortletTilesResult.java | 25 ++++++------------- pom.xml | 5 ++++ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml index c2793d769..333c5701a 100644 --- a/plugins/portlet-tiles/pom.xml +++ b/plugins/portlet-tiles/pom.xml @@ -42,6 +42,10 @@ org.apache.struts struts2-portlet-plugin + + org.apache.tiles + tiles-portlet + javax.servlet jsp-api 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 c08a99bb3..ea134d82e 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 @@ -9,6 +9,7 @@ import org.apache.struts2.portlet.context.PortletActionContext; import org.apache.tiles.TilesContainer; import org.apache.tiles.TilesException; import org.apache.tiles.access.TilesAccess; +import org.apache.tiles.portlet.context.PortletUtil; import javax.portlet.ActionResponse; import javax.portlet.PortletException; @@ -19,11 +20,13 @@ import java.io.IOException; import java.util.Map; /** - * JIRA WW-2749 (STRUTS). + * Dedicated Tile result to be used in Portlet environment + * + * WW-2749 */ public class PortletTilesResult extends ServletDispatcherResult { - private static final long serialVersionUID = -3806939435493086244L; + public static final String TILES_ACTION_NAME = "tilesDirect"; public PortletTilesResult() { super(); @@ -33,10 +36,7 @@ public class PortletTilesResult extends ServletDispatcherResult { super(location); } - // FIXME PATCH du JIRA WW-2749 (STRUTS) - public void doExecute(String location, ActionInvocation invocation) - throws IOException, TemplateException, PortletException, TilesException { - + public void doExecute(String location, ActionInvocation invocation) throws Exception { if (PortletActionContext.getPhase().isAction() || PortletActionContext.getPhase().isEvent()) { executeActionResult(location, invocation); } else { @@ -44,15 +44,10 @@ public class PortletTilesResult extends ServletDispatcherResult { } } - /** - * @param location - * @throws TilesException - */ protected void executeRenderResult(String location) throws TilesException { setLocation(location); - ServletContext servletContext = ServletActionContext.getServletContext(); - TilesContainer container = TilesAccess.getContainer(servletContext); + TilesContainer container = PortletUtil.getContainer(PortletActionContext.getPortletContext()); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); @@ -60,14 +55,10 @@ public class PortletTilesResult extends ServletDispatcherResult { container.render(location, request, response); } - /** - * @param location - * @param invocation - */ protected void executeActionResult(String location, ActionInvocation invocation) { ActionResponse res = PortletActionContext.getActionResponse(); - res.setRenderParameter(PortletConstants.ACTION_PARAM, "tilesDirect"); + res.setRenderParameter(PortletConstants.ACTION_PARAM, TILES_ACTION_NAME); Map sessionMap = invocation.getInvocationContext().getSession(); sessionMap.put(PortletConstants.RENDER_DIRECT_LOCATION, location); diff --git a/pom.xml b/pom.xml index 6f6ea8aaa..7f45aeadb 100644 --- a/pom.xml +++ b/pom.xml @@ -678,6 +678,11 @@ tiles-servlet ${tiles.version} + + org.apache.tiles + tiles-portlet + ${tiles.version} + org.apache.tiles tiles-jsp