<portlet>\r
<portlet-name>PortletDemoPortlet</portlet-name>\r
<display-name>IT Mill Toolkit PortletDemo</display-name>\r
- <portlet-class>com.itmill.toolkit.terminal.gwt.server.ITMillApplicationPortlet</portlet-class>\r
+ <portlet-class>com.itmill.toolkit.terminal.gwt.server.ApplicationPortlet</portlet-class>\r
<init-param>\r
<name>application</name>\r
<value>PortletDemo</value>\r
<portlet>\r
<portlet-name>FeatureBrowserPortlet</portlet-name>\r
<display-name>IT Mill Toolkit FeatureBrowser</display-name>\r
- <portlet-class>com.itmill.toolkit.terminal.gwt.server.ITMillApplicationPortlet</portlet-class>\r
+ <portlet-class>com.itmill.toolkit.terminal.gwt.server.ApplicationPortlet</portlet-class>\r
<init-param>\r
<name>application</name>\r
<value>FeatureBrowser</value>\r
<portlet>\r
<portlet-name>CalcPortlet</portlet-name>\r
<display-name>IT Mill Toolkit Calc</display-name>\r
- <portlet-class>com.itmill.toolkit.terminal.gwt.server.ITMillApplicationPortlet</portlet-class>\r
+ <portlet-class>com.itmill.toolkit.terminal.gwt.server.ApplicationPortlet</portlet-class>\r
<init-param>\r
<name>application</name>\r
<value>Calc</value>\r
--- /dev/null
+package com.itmill.toolkit.terminal.gwt.server;\r
+\r
+import java.io.IOException;\r
+import java.io.PrintWriter;\r
+\r
+import javax.portlet.ActionRequest;\r
+import javax.portlet.ActionResponse;\r
+import javax.portlet.Portlet;\r
+import javax.portlet.PortletConfig;\r
+import javax.portlet.PortletException;\r
+import javax.portlet.PortletRequestDispatcher;\r
+import javax.portlet.PortletSession;\r
+import javax.portlet.RenderRequest;\r
+import javax.portlet.RenderResponse;\r
+\r
+import com.itmill.toolkit.Application;\r
+\r
+public class ApplicationPortlet implements Portlet {\r
+ // The application to show\r
+ protected String app = "Calc";\r
+ // some applications might require that the height is specified\r
+ protected String height = null; // e.g "200px"\r
+\r
+ private PortletConfig config;\r
+\r
+ public void destroy() {\r
+ config = null;\r
+ }\r
+\r
+ public void init(PortletConfig config) throws PortletException {\r
+ this.config = config;\r
+ app = config.getInitParameter("application");\r
+ if (app == null) {\r
+ app = "PortletDemo";\r
+ }\r
+ height = config.getInitParameter("height");\r
+ }\r
+\r
+ public void processAction(ActionRequest request, ActionResponse response)\r
+ throws PortletException, IOException {\r
+ PortletApplicationContext.dispatchRequest(this, request, response);\r
+ }\r
+\r
+ public void render(RenderRequest request, RenderResponse response)\r
+ throws PortletException, IOException {\r
+\r
+ // display the IT Mill Toolkit application\r
+ writeAjaxWindow(request, response);\r
+ }\r
+\r
+ protected void writeAjaxWindow(RenderRequest request,\r
+ RenderResponse response) throws IOException {\r
+\r
+ response.setContentType("text/html");\r
+ PrintWriter out = response.getWriter();\r
+\r
+ if (app != null) {\r
+ PortletSession sess = request.getPortletSession();\r
+ PortletApplicationContext ctx = PortletApplicationContext\r
+ .getApplicationContext(sess);\r
+\r
+ /*- TODO store som info somewhere?\r
+ PortletInfo pi = ctx.setPortletInfo(request.getContextPath() + "/"\r
+ + app + (app.endsWith("/") ? "" : "/"), request\r
+ .getPortletMode(), request.getWindowState(), request\r
+ .getUserPrincipal(), (Map) request\r
+ .getAttribute(PortletRequest.USER_INFO), config);\r
+ -*/\r
+\r
+ PortletRequestDispatcher dispatcher = sess.getPortletContext()\r
+ .getRequestDispatcher("/" + app);\r
+\r
+ try {\r
+ // TODO height\r
+ dispatcher.include(request, response);\r
+\r
+ } catch (PortletException e) {\r
+ out.print("<h1>Servlet include failed!</h1>");\r
+ out.print("<div>" + e + "</div>");\r
+ ctx.setPortletApplication(this, null);\r
+ return;\r
+ }\r
+\r
+ Application app = (Application) request\r
+ .getAttribute(Application.class.getName());\r
+ ctx.setPortletApplication(this, app);\r
+ ctx.firePortletRenderRequest(this, request, response);\r
+\r
+ }\r
+ }\r
+\r
+}\r
+++ /dev/null
-package com.itmill.toolkit.terminal.gwt.server;\r
-\r
-import java.io.IOException;\r
-import java.io.PrintWriter;\r
-\r
-import javax.portlet.ActionRequest;\r
-import javax.portlet.ActionResponse;\r
-import javax.portlet.Portlet;\r
-import javax.portlet.PortletConfig;\r
-import javax.portlet.PortletException;\r
-import javax.portlet.PortletRequestDispatcher;\r
-import javax.portlet.PortletSession;\r
-import javax.portlet.RenderRequest;\r
-import javax.portlet.RenderResponse;\r
-\r
-import com.itmill.toolkit.Application;\r
-\r
-public class ITMillApplicationPortlet implements Portlet {\r
- // The application to show\r
- protected String app = "Calc";\r
- // some applications might require that the height is specified\r
- protected String height = null; // e.g "200px"\r
-\r
- private PortletConfig config;\r
-\r
- public void destroy() {\r
- config = null;\r
- }\r
-\r
- public void init(PortletConfig config) throws PortletException {\r
- this.config = config;\r
- app = config.getInitParameter("application");\r
- if (app == null) {\r
- app = "PortletDemo";\r
- }\r
- height = config.getInitParameter("height");\r
- }\r
-\r
- public void processAction(ActionRequest request, ActionResponse response)\r
- throws PortletException, IOException {\r
- PortletApplicationContext.dispatchRequest(this, request, response);\r
- }\r
-\r
- public void render(RenderRequest request, RenderResponse response)\r
- throws PortletException, IOException {\r
-\r
- /*-\r
- PortletPreferences prefs = request.getPreferences();\r
- app = prefs.getValue("application", app);\r
- theme = prefs.getValue("theme", "default");\r
- height = prefs.getValue("height", null);\r
- -*/\r
-\r
- // display the IT Mill Toolkit application\r
- writeAjaxWindow(request, response);\r
- }\r
-\r
- protected void writeAjaxWindow(RenderRequest request,\r
- RenderResponse response) throws IOException {\r
-\r
- response.setContentType("text/html");\r
- PrintWriter out = response.getWriter();\r
-\r
- if (app != null) {\r
- PortletSession sess = request.getPortletSession();\r
- PortletApplicationContext ctx = PortletApplicationContext\r
- .getApplicationContext(sess);\r
-\r
- /*- TODO store som info somewhere?\r
- PortletInfo pi = ctx.setPortletInfo(request.getContextPath() + "/"\r
- + app + (app.endsWith("/") ? "" : "/"), request\r
- .getPortletMode(), request.getWindowState(), request\r
- .getUserPrincipal(), (Map) request\r
- .getAttribute(PortletRequest.USER_INFO), config);\r
- -*/\r
-\r
- PortletRequestDispatcher dispatcher = sess.getPortletContext()\r
- .getRequestDispatcher("/" + app);\r
-\r
- try {\r
- // TODO remove:\r
-\r
- System.err.println(request.getContextPath() + " (portlet ctx)");\r
- // TODO height\r
- dispatcher.include(request, response);\r
-\r
- } catch (PortletException e) {\r
- out.print("<h1>Servlet include failed!</h1>");\r
- out.print("<div>" + e + "</div>");\r
- ctx.setPortletApplication(this, null);\r
- return;\r
- }\r
-\r
- Application app = (Application) request\r
- .getAttribute(Application.class.getName());\r
- ctx.setPortletApplication(this, app);\r
- ctx.firePortletRenderRequest(this, request, response);\r
-\r
- }\r
- }\r
-\r
-}\r
\r
static public PortletApplicationContext getApplicationContext(\r
PortletSession session) {\r
- System.err.println("PortletApplicationContext.getApplicationContext");\r
WebApplicationContext cx = (WebApplicationContext) session\r
.getAttribute(WebApplicationContext.class.getName(),\r
PortletSession.APPLICATION_SCOPE);\r
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++) {
.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 + "/";