From: Marc Englund Date: Tue, 15 Apr 2008 09:16:32 +0000 (+0000) Subject: Strange Liferay / Portlet problem fixed, intermediate commit. X-Git-Tag: 6.7.0.beta1~4895 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=671708d240a998f33b32c9759270312ff5c83697;p=vaadin-framework.git Strange Liferay / Portlet problem fixed, intermediate commit. svn changeset:4177/svn branch:trunk --- diff --git a/WebContent/WEB-INF/liferay-display.xml b/WebContent/WEB-INF/liferay-display.xml index 8ba4a93f7f..c0a3308aa3 100644 --- a/WebContent/WEB-INF/liferay-display.xml +++ b/WebContent/WEB-INF/liferay-display.xml @@ -3,8 +3,8 @@ - - - + + + \ No newline at end of file diff --git a/WebContent/WEB-INF/liferay-portlet.xml b/WebContent/WEB-INF/liferay-portlet.xml index d445af65a7..d863fdac60 100644 --- a/WebContent/WEB-INF/liferay-portlet.xml +++ b/WebContent/WEB-INF/liferay-portlet.xml @@ -4,17 +4,17 @@ - PortletDemo + PortletDemoPortlet true false - Calc + CalcPortlet true false - FeatureBrowser + FeatureBrowserPortlet true false diff --git a/WebContent/WEB-INF/portlet.xml b/WebContent/WEB-INF/portlet.xml index e0b00b5dae..dc48102bc5 100644 --- a/WebContent/WEB-INF/portlet.xml +++ b/WebContent/WEB-INF/portlet.xml @@ -5,9 +5,9 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> - PortletDemo + PortletDemoPortlet IT Mill Toolkit PortletDemo - com.itmill.toolkit.terminal.gwt.server.ApplicationPortlet + com.itmill.toolkit.terminal.gwt.server.ITMillApplicationPortlet application PortletDemo @@ -37,9 +37,9 @@ - FeatureBrowser + FeatureBrowserPortlet IT Mill Toolkit FeatureBrowser - com.itmill.toolkit.terminal.gwt.server.ApplicationPortlet + com.itmill.toolkit.terminal.gwt.server.ITMillApplicationPortlet application FeatureBrowser @@ -69,9 +69,9 @@ - Calc + CalcPortlet IT Mill Toolkit Calc - com.itmill.toolkit.terminal.gwt.server.ApplicationPortlet + com.itmill.toolkit.terminal.gwt.server.ITMillApplicationPortlet application Calc diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 78508e6b67..02817d0816 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -20,7 +20,7 @@ testingToolsServerUri - http://192.168.1.120:8099/TestingToolsServer + http://192.168.1.242:8099/TestingToolsServer IT Mill Testing Tools URI @@ -383,6 +383,19 @@ com.itmill.toolkit.demo.WindowedDemos + + + PortletDemo + com.itmill.toolkit.terminal.gwt.server.ApplicationServlet + + application + com.itmill.toolkit.demo.PortletDemo + + + + PortletDemo + /PortletDemo/* + ITMillToolkitApplicationRunner diff --git a/portlet-src/com/itmill/toolkit/demo/PortletDemo.java b/portlet-src/com/itmill/toolkit/demo/PortletDemo.java index d519874812..98859653f0 100644 --- a/portlet-src/com/itmill/toolkit/demo/PortletDemo.java +++ b/portlet-src/com/itmill/toolkit/demo/PortletDemo.java @@ -37,10 +37,8 @@ public class PortletDemo extends Application { tf.setEnabled(false); main.addComponent(tf); - portletEdit.setCaption("Portlet edit/view"); portletEdit.setEnabled(false); main.addComponent(portletEdit); - portletMax.setCaption("Maximize/normal portlet"); portletMax.setEnabled(false); main.addComponent(portletMax); @@ -48,7 +46,8 @@ public class PortletDemo extends Application { PortletApplicationContext ctx = (PortletApplicationContext) getContext(); ctx.addPortletListener(this, new DemoPortletListener()); } else { - getMainWindow().showNotification("Not inited via Portal!"); + getMainWindow().showNotification("Not inited via Portal!", + Notification.TYPE_ERROR_MESSAGE); } } @@ -64,11 +63,15 @@ public class PortletDemo extends Application { public void handleRenderRequest(RenderRequest request, RenderResponse response) { + portletEdit.setEnabled(true); + portletMax.setEnabled(true); + tf.setEnabled((request.getPortletMode() == PortletMode.EDIT)); + getMainWindow().showNotification( "Portlet status", - "mode: " + request.getPortletMode() + "
state: " + "Mode: " + request.getPortletMode() + " State: " + request.getWindowState(), - Notification.TYPE_TRAY_NOTIFICATION); + Notification.TYPE_WARNING_MESSAGE); PortletURL url = response.createActionURL(); try { @@ -76,6 +79,9 @@ public class PortletDemo extends Application { .setPortletMode((request.getPortletMode() == PortletMode.VIEW ? PortletMode.EDIT : PortletMode.VIEW)); portletEdit.setResource(new ExternalResource(url.toString())); + portletEdit + .setCaption((request.getPortletMode() == PortletMode.VIEW ? "Edit" + : "Done")); } catch (Exception e) { portletEdit.setEnabled(false); } @@ -85,9 +91,12 @@ public class PortletDemo extends Application { url .setWindowState((request.getWindowState() == WindowState.NORMAL ? WindowState.MAXIMIZED : WindowState.NORMAL)); - portletEdit.setResource(new ExternalResource(url.toString())); + portletMax.setResource(new ExternalResource(url.toString())); + portletMax + .setCaption((request.getWindowState() == WindowState.NORMAL ? "Maximize" + : "Back to normal")); } catch (Exception e) { - portletEdit.setEnabled(false); + portletMax.setEnabled(false); } } diff --git a/portlet-src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java b/portlet-src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java deleted file mode 100644 index 5a924cd41a..0000000000 --- a/portlet-src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.itmill.toolkit.terminal.gwt.server; - -import java.io.IOException; -import java.io.PrintWriter; - -import javax.portlet.ActionRequest; -import javax.portlet.ActionResponse; -import javax.portlet.Portlet; -import javax.portlet.PortletConfig; -import javax.portlet.PortletException; -import javax.portlet.PortletRequestDispatcher; -import javax.portlet.PortletSession; -import javax.portlet.RenderRequest; -import javax.portlet.RenderResponse; - -import com.itmill.toolkit.Application; - -public class ApplicationPortlet implements Portlet { - // The application to show - protected String app = "Calc"; - // some applications might require that the height is specified - protected String height = null; // e.g "200px" - - private PortletConfig config; - - public void destroy() { - config = null; - } - - public void init(PortletConfig config) throws PortletException { - this.config = config; - app = config.getInitParameter("application"); - if (app == null) { - app = "PortletDemo"; - } - height = config.getInitParameter("height"); - } - - public void processAction(ActionRequest request, ActionResponse response) - throws PortletException, IOException { - PortletApplicationContext.dispatchRequest(this, request, response); - } - - 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); - } - - protected void writeAjaxWindow(RenderRequest request, - RenderResponse response) throws IOException { - - response.setContentType("text/html"); - PrintWriter out = response.getWriter(); - - out.println("

WTF?

"); - - if (app != null) { - System.err.println("WTFFF???"); - PortletSession sess = request.getPortletSession(); - PortletApplicationContext ctx = PortletApplicationContext - .getApplicationContext(sess); - - /*- TODO store som info somewhere? - PortletInfo pi = ctx.setPortletInfo(request.getContextPath() + "/" - + app + (app.endsWith("/") ? "" : "/"), request - .getPortletMode(), request.getWindowState(), request - .getUserPrincipal(), (Map) request - .getAttribute(PortletRequest.USER_INFO), config); - -*/ - - PortletRequestDispatcher dispatcher = sess.getPortletContext() - .getRequestDispatcher( - "/" + request.getContextPath() + "/" + app); - - try { - // TODO remove: - - System.err.println(request.getContextPath() + " (portlet ctx)"); - // TODO height - dispatcher.include(request, response); - - } catch (PortletException e) { - out.print("

Servlet include failed!

"); - out.print("
" + e + "
"); - ctx.setPortletApplication(this, null); - return; - } - - Application app = (Application) request - .getAttribute(Application.class.getName()); - ctx.setPortletApplication(this, app); - ctx.firePortletRenderRequest(this, request, response); - - } - } - -} diff --git a/portlet-src/com/itmill/toolkit/terminal/gwt/server/ITMillApplicationPortlet.java b/portlet-src/com/itmill/toolkit/terminal/gwt/server/ITMillApplicationPortlet.java new file mode 100644 index 0000000000..7c744dc4c2 --- /dev/null +++ b/portlet-src/com/itmill/toolkit/terminal/gwt/server/ITMillApplicationPortlet.java @@ -0,0 +1,102 @@ +package com.itmill.toolkit.terminal.gwt.server; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.Portlet; +import javax.portlet.PortletConfig; +import javax.portlet.PortletException; +import javax.portlet.PortletRequestDispatcher; +import javax.portlet.PortletSession; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import com.itmill.toolkit.Application; + +public class ITMillApplicationPortlet implements Portlet { + // The application to show + protected String app = "Calc"; + // some applications might require that the height is specified + protected String height = null; // e.g "200px" + + private PortletConfig config; + + public void destroy() { + config = null; + } + + public void init(PortletConfig config) throws PortletException { + this.config = config; + app = config.getInitParameter("application"); + if (app == null) { + app = "PortletDemo"; + } + height = config.getInitParameter("height"); + } + + public void processAction(ActionRequest request, ActionResponse response) + throws PortletException, IOException { + PortletApplicationContext.dispatchRequest(this, request, response); + } + + 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); + } + + protected void writeAjaxWindow(RenderRequest request, + RenderResponse response) throws IOException { + + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + + if (app != null) { + PortletSession sess = request.getPortletSession(); + PortletApplicationContext ctx = PortletApplicationContext + .getApplicationContext(sess); + + /*- TODO store som info somewhere? + PortletInfo pi = ctx.setPortletInfo(request.getContextPath() + "/" + + app + (app.endsWith("/") ? "" : "/"), request + .getPortletMode(), request.getWindowState(), request + .getUserPrincipal(), (Map) request + .getAttribute(PortletRequest.USER_INFO), config); + -*/ + + PortletRequestDispatcher dispatcher = sess.getPortletContext() + .getRequestDispatcher("/" + app); + + try { + // TODO remove: + + System.err.println(request.getContextPath() + " (portlet ctx)"); + // TODO height + dispatcher.include(request, response); + + } catch (PortletException e) { + out.print("

Servlet include failed!

"); + out.print("
" + e + "
"); + ctx.setPortletApplication(this, null); + return; + } + + Application app = (Application) request + .getAttribute(Application.class.getName()); + ctx.setPortletApplication(this, app); + ctx.firePortletRenderRequest(this, request, response); + + } + } + +}