From 177ffe19adb272f841d543e6d1a178d59d363226 Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Tue, 15 Apr 2008 12:12:15 +0000 Subject: [PATCH] Portlet integration refactoring, ApplicationServlet changes. svn changeset:4179/svn branch:trunk --- WebContent/WEB-INF/portlet.xml | 6 ++-- ...onPortlet.java => ApplicationPortlet.java} | 12 +------- .../gwt/server/PortletApplicationContext.java | 1 - .../gwt/server/ApplicationServlet.java | 30 ++++++++++++++++--- 4 files changed, 30 insertions(+), 19 deletions(-) rename portlet-src/com/itmill/toolkit/terminal/gwt/server/{ITMillApplicationPortlet.java => ApplicationPortlet.java} (85%) diff --git a/WebContent/WEB-INF/portlet.xml b/WebContent/WEB-INF/portlet.xml index dc48102bc5..6edf435c80 100644 --- a/WebContent/WEB-INF/portlet.xml +++ b/WebContent/WEB-INF/portlet.xml @@ -7,7 +7,7 @@ PortletDemoPortlet IT Mill Toolkit PortletDemo - com.itmill.toolkit.terminal.gwt.server.ITMillApplicationPortlet + com.itmill.toolkit.terminal.gwt.server.ApplicationPortlet application PortletDemo @@ -39,7 +39,7 @@ FeatureBrowserPortlet IT Mill Toolkit FeatureBrowser - com.itmill.toolkit.terminal.gwt.server.ITMillApplicationPortlet + com.itmill.toolkit.terminal.gwt.server.ApplicationPortlet application FeatureBrowser @@ -71,7 +71,7 @@ CalcPortlet IT Mill Toolkit Calc - com.itmill.toolkit.terminal.gwt.server.ITMillApplicationPortlet + com.itmill.toolkit.terminal.gwt.server.ApplicationPortlet application Calc diff --git a/portlet-src/com/itmill/toolkit/terminal/gwt/server/ITMillApplicationPortlet.java b/portlet-src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java similarity index 85% rename from portlet-src/com/itmill/toolkit/terminal/gwt/server/ITMillApplicationPortlet.java rename to portlet-src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java index 7c744dc4c2..e21a1b01f1 100644 --- a/portlet-src/com/itmill/toolkit/terminal/gwt/server/ITMillApplicationPortlet.java +++ b/portlet-src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java @@ -15,7 +15,7 @@ import javax.portlet.RenderResponse; import com.itmill.toolkit.Application; -public class ITMillApplicationPortlet implements Portlet { +public class ApplicationPortlet implements Portlet { // The application to show protected String app = "Calc"; // some applications might require that the height is specified @@ -44,13 +44,6 @@ public class ITMillApplicationPortlet implements Portlet { public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { - /*- - PortletPreferences prefs = request.getPreferences(); - app = prefs.getValue("application", app); - theme = prefs.getValue("theme", "default"); - height = prefs.getValue("height", null); - -*/ - // display the IT Mill Toolkit application writeAjaxWindow(request, response); } @@ -78,9 +71,6 @@ public class ITMillApplicationPortlet implements Portlet { .getRequestDispatcher("/" + app); try { - // TODO remove: - - System.err.println(request.getContextPath() + " (portlet ctx)"); // TODO height dispatcher.include(request, response); diff --git a/portlet-src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java b/portlet-src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java index 46c28e72ca..4ddbabdb96 100644 --- a/portlet-src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java +++ b/portlet-src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java @@ -42,7 +42,6 @@ public class PortletApplicationContext extends WebApplicationContext { static public PortletApplicationContext getApplicationContext( PortletSession session) { - System.err.println("PortletApplicationContext.getApplicationContext"); WebApplicationContext cx = (WebApplicationContext) session .getAttribute(WebApplicationContext.class.getName(), PortletSession.APPLICATION_SCOPE); diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java index 63ec172b8c..88103d90bf 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java @@ -651,12 +651,24 @@ public class ApplicationServlet extends HttpServlet { String[] urlParts; try { urlParts = getApplicationUrl(request).toString().split("\\/"); + // TODO remove: + System.err.println(getApplicationUrl(request).toString() + + " parts: " + urlParts.length); + System.err.println(request.getContextPath() + "(servlet ctx)"); appUrl = ""; widgetsetUrl = ""; // if context is specified add it to widgetsetUrl + String ctxPath = request.getContextPath(); + if (ctxPath.length() == 0 + && request + .getAttribute("javax.servlet.include.context_path") != null) { + // include request (e.g portlet), get contex path from + // attribute + ctxPath = (String) request + .getAttribute("javax.servlet.include.context_path"); + } if (urlParts.length > 3 - && urlParts[3].equals(request.getContextPath() - .replaceAll("\\/", ""))) { + && urlParts[3].equals(ctxPath.replaceAll("\\/", ""))) { widgetsetUrl += "/" + urlParts[3]; } for (int i = 3; i < urlParts.length; i++) { @@ -1066,8 +1078,18 @@ public class ApplicationServlet extends HttpServlet { .getServerPort() == 80) ? "" : ":" + request.getServerPort()) + request.getRequestURI()); - String servletPath = request.getContextPath() - + request.getServletPath(); + String servletPath = ""; + if (request.getAttribute("javax.servlet.include.servlet_path") != null) { + // this is an include request + servletPath = request.getAttribute( + "javax.servlet.include.context_path").toString() + + request + .getAttribute("javax.servlet.include.servlet_path"); + + } else { + servletPath = request.getContextPath() + + request.getServletPath(); + } if (servletPath.length() == 0 || servletPath.charAt(servletPath.length() - 1) != '/') { servletPath = servletPath + "/"; -- 2.39.5