From: Marc Englund Date: Tue, 15 Apr 2008 06:40:59 +0000 (+0000) Subject: Fixed typo, continuing devel. X-Git-Tag: 6.7.0.beta1~4896 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c95bf3d9ff40e79174536905450c9e62b4ef3eee;p=vaadin-framework.git Fixed typo, continuing devel. svn changeset:4176/svn branch:trunk --- diff --git a/portlet-src/com/itmill/tookit/demo/PortletDemo.java b/portlet-src/com/itmill/tookit/demo/PortletDemo.java deleted file mode 100644 index 7e57132466..0000000000 --- a/portlet-src/com/itmill/tookit/demo/PortletDemo.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * - */ -package com.itmill.tookit.demo; - -import javax.portlet.ActionRequest; -import javax.portlet.ActionResponse; -import javax.portlet.PortletMode; -import javax.portlet.PortletURL; -import javax.portlet.RenderRequest; -import javax.portlet.RenderResponse; -import javax.portlet.WindowState; - -import com.itmill.toolkit.Application; -import com.itmill.toolkit.terminal.ExternalResource; -import com.itmill.toolkit.terminal.gwt.server.PortletApplicationContext; -import com.itmill.toolkit.terminal.gwt.server.PortletApplicationContext.PortletListener; -import com.itmill.toolkit.ui.Link; -import com.itmill.toolkit.ui.TextField; -import com.itmill.toolkit.ui.Window; -import com.itmill.toolkit.ui.Window.Notification; - -/** - * @author marc - * - */ -public class PortletDemo extends Application { - - Window main = new Window(); - TextField tf = new TextField(); - Link portletEdit = new Link(); - Link portletMax = new Link(); - - public void init() { - main = new Window(); - 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); - - PortletApplicationContext ctx = (PortletApplicationContext) getContext(); - - ctx.addPortletListener(this, new DemoPortletListener()); - } - - private class DemoPortletListener implements PortletListener { - - public void handleActionRequest(ActionRequest request, - ActionResponse response) { - - getMainWindow().showNotification("Action received"); - - } - - public void handleRenderRequest(RenderRequest request, - RenderResponse response) { - getMainWindow().showNotification( - "Portlet status", - "mode: " + request.getPortletMode() + "
state: " - + request.getWindowState(), - Notification.TYPE_TRAY_NOTIFICATION); - - PortletURL url = response.createActionURL(); - try { - url - .setPortletMode((request.getPortletMode() == PortletMode.VIEW ? PortletMode.EDIT - : PortletMode.VIEW)); - portletEdit.setResource(new ExternalResource(url.toString())); - } catch (Exception e) { - portletEdit.setEnabled(false); - } - - url = response.createActionURL(); - try { - url - .setWindowState((request.getWindowState() == WindowState.NORMAL ? WindowState.MAXIMIZED - : WindowState.NORMAL)); - portletEdit.setResource(new ExternalResource(url.toString())); - } catch (Exception e) { - portletEdit.setEnabled(false); - } - - } - } -} diff --git a/portlet-src/com/itmill/toolkit/demo/PortletDemo.java b/portlet-src/com/itmill/toolkit/demo/PortletDemo.java new file mode 100644 index 0000000000..d519874812 --- /dev/null +++ b/portlet-src/com/itmill/toolkit/demo/PortletDemo.java @@ -0,0 +1,95 @@ +/** + * + */ +package com.itmill.toolkit.demo; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletMode; +import javax.portlet.PortletURL; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.WindowState; + +import com.itmill.toolkit.Application; +import com.itmill.toolkit.terminal.ExternalResource; +import com.itmill.toolkit.terminal.gwt.server.PortletApplicationContext; +import com.itmill.toolkit.terminal.gwt.server.PortletApplicationContext.PortletListener; +import com.itmill.toolkit.ui.Link; +import com.itmill.toolkit.ui.TextField; +import com.itmill.toolkit.ui.Window; +import com.itmill.toolkit.ui.Window.Notification; + +/** + * @author marc + * + */ +public class PortletDemo extends Application { + + Window main = new Window(); + TextField tf = new TextField(); + Link portletEdit = new Link(); + Link portletMax = new Link(); + + public void init() { + main = new Window(); + setMainWindow(main); + 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); + + if (getContext() instanceof PortletApplicationContext) { + PortletApplicationContext ctx = (PortletApplicationContext) getContext(); + ctx.addPortletListener(this, new DemoPortletListener()); + } else { + getMainWindow().showNotification("Not inited via Portal!"); + } + + } + + private class DemoPortletListener implements PortletListener { + + public void handleActionRequest(ActionRequest request, + ActionResponse response) { + + getMainWindow().showNotification("Action received"); + + } + + public void handleRenderRequest(RenderRequest request, + RenderResponse response) { + getMainWindow().showNotification( + "Portlet status", + "mode: " + request.getPortletMode() + "
state: " + + request.getWindowState(), + Notification.TYPE_TRAY_NOTIFICATION); + + PortletURL url = response.createActionURL(); + try { + url + .setPortletMode((request.getPortletMode() == PortletMode.VIEW ? PortletMode.EDIT + : PortletMode.VIEW)); + portletEdit.setResource(new ExternalResource(url.toString())); + } catch (Exception e) { + portletEdit.setEnabled(false); + } + + url = response.createActionURL(); + try { + url + .setWindowState((request.getWindowState() == WindowState.NORMAL ? WindowState.MAXIMIZED + : WindowState.NORMAL)); + portletEdit.setResource(new ExternalResource(url.toString())); + } catch (Exception e) { + portletEdit.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 index bb88456059..5a924cd41a 100644 --- a/portlet-src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java +++ b/portlet-src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java @@ -17,7 +17,7 @@ import com.itmill.toolkit.Application; public class ApplicationPortlet implements Portlet { // The application to show - protected String app = "PortletDemo"; + protected String app = "Calc"; // some applications might require that the height is specified protected String height = null; // e.g "200px" @@ -31,7 +31,7 @@ public class ApplicationPortlet implements Portlet { this.config = config; app = config.getInitParameter("application"); if (app == null) { - app = "PortalDemo"; + app = "PortletDemo"; } height = config.getInitParameter("height"); } @@ -61,8 +61,10 @@ public class ApplicationPortlet implements Portlet { response.setContentType("text/html"); PrintWriter out = response.getWriter(); - if (app != null) { + out.println("

WTF?

"); + if (app != null) { + System.err.println("WTFFF???"); PortletSession sess = request.getPortletSession(); PortletApplicationContext ctx = PortletApplicationContext .getApplicationContext(sess); @@ -76,11 +78,16 @@ public class ApplicationPortlet implements Portlet { -*/ PortletRequestDispatcher dispatcher = sess.getPortletContext() - .getRequestDispatcher("/" + app); + .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 + "
"); 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 4ddbabdb96..46c28e72ca 100644 --- a/portlet-src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java +++ b/portlet-src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java @@ -42,6 +42,7 @@ 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);