mirror of
https://github.com/apache/struts.git
synced 2026-08-07 07:37:20 +00:00
Migrates tiles-portlet to the same version
This commit is contained in:
@@ -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>
|
||||
|
||||
+37
-13
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.3</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>
|
||||
|
||||
Reference in New Issue
Block a user