From: Petter Holmström Date: Tue, 3 Nov 2009 09:45:56 +0000 (+0000) Subject: Now the Calc application works on Liferay. X-Git-Tag: 6.7.0.beta1~2266^2~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1101a2f9e45bdacb51425950c05b805f54586375;p=vaadin-framework.git Now the Calc application works on Liferay. svn changeset:9600/svn branch:portlet_2.0 --- diff --git a/WebContent/WEB-INF/liferay-display.xml b/WebContent/WEB-INF/liferay-display.xml index f5bbc414f2..73e43478ef 100644 --- a/WebContent/WEB-INF/liferay-display.xml +++ b/WebContent/WEB-INF/liferay-display.xml @@ -14,6 +14,8 @@ - + + + \ No newline at end of file diff --git a/WebContent/WEB-INF/liferay-portlet.xml b/WebContent/WEB-INF/liferay-portlet.xml index 5217414ea7..eecb32eb15 100644 --- a/WebContent/WEB-INF/liferay-portlet.xml +++ b/WebContent/WEB-INF/liferay-portlet.xml @@ -57,7 +57,21 @@ true false - + + HelloWorldPortlet + true + false + + + AddressBookPortlet + true + false + + + CalcPortlet + true + false + administrator Administrator diff --git a/WebContent/WEB-INF/portlet.xml b/WebContent/WEB-INF/portlet.xml index 88c3fa9a5b..719560852c 100644 --- a/WebContent/WEB-INF/portlet.xml +++ b/WebContent/WEB-INF/portlet.xml @@ -1,185 +1,258 @@ - - - PortletDemoPortlet - Vaadin PortletDemo - com.vaadin.terminal.gwt.server.ApplicationPortlet - - application - PortletDemo - - - widgetsetcom.vaadin.demo.reservation.gwt.ReservationWidgetSet - - text/html - view - edit - help - - - PortletDemo - PortletDemo - - - - administrator - - - guest - - - power-user - - - user - - - - SimpleReserverPortlet - Vaadin SimpleReserver - com.vaadin.terminal.gwt.server.ApplicationPortlet - - application - SimpleReserver - - stylestyle=height:400px - widgetsetcom.vaadin.demo.reservation.gwt.ReservationWidgetSet - - text/html - view - edit - help - - - SimpleReserver - SimpleReserver - - - - administrator - - - guest - - - power-user - - - user - - - - FeatureBrowserPortlet - Vaadin FeatureBrowser - com.vaadin.terminal.gwt.server.ApplicationPortlet2 - - application - com.vaadin.tests.featurebrowser.FeaturesApplication - - stylestyle=height:650px - widgetsetcom.vaadin.demo.reservation.gwt.ReservationWidgetSet - - text/html - view - edit - help - - - FeatureBrowser - FeatureBrowser - - - - administrator - - - guest - - - power-user - - - user - - - - ChatServletPortlet - Vaadin ChatServlet - com.vaadin.terminal.gwt.server.ApplicationPortlet - - application - chat - - - widgetsetcom.vaadin.demo.reservation.gwt.ReservationWidgetSet - - text/html - view - edit - help - - - ChatServlet - ChatServlet - - - - administrator - - - guest - - - power-user - - - user - - - - BrowserDemoPortlet - Vaadin BrowserDemo - com.vaadin.terminal.gwt.server.ApplicationPortlet - - application - BrowserDemo - - stylestyle=height:650px - widgetsetcom.vaadin.demo.reservation.gwt.ReservationWidgetSet - - text/html - view - edit - help - - - BrowserDemo - BrowserDemo - - - - administrator - - - guest - - - power-user - - - user - - + + + PortletDemoPortlet + Vaadin PortletDemo + com.vaadin.terminal.gwt.server.ApplicationPortlet2 + + application + com.vaadin.demo.PortletDemo + - + + widgetset + com.vaadin.demo.reservation.gwt.ReservationWidgetSet + + + text/html + view + edit + help + + + PortletDemo + PortletDemo + + + + administrator + + + guest + + + power-user + + + user + + + + SimpleReserverPortlet + Vaadin SimpleReserver + com.vaadin.terminal.gwt.server.ApplicationPortlet + + application + SimpleReserver + + + style + style=height:400px + + + widgetset + com.vaadin.demo.reservation.gwt.ReservationWidgetSet + + + text/html + view + edit + help + + + SimpleReserver + SimpleReserver + + + + administrator + + + guest + + + power-user + + + user + + + + FeatureBrowserPortlet + Vaadin FeatureBrowser + com.vaadin.terminal.gwt.server.ApplicationPortlet2 + + application + com.vaadin.tests.featurebrowser.FeaturesApplication + + + style + style=height:650px + + + widgetset + com.vaadin.demo.reservation.gwt.ReservationWidgetSet + + + text/html + view + edit + help + + + FeatureBrowser + FeatureBrowser + + + + administrator + + + guest + + + power-user + + + user + + + + HelloWorldPortlet + Hello World + com.vaadin.terminal.gwt.server.ApplicationPortlet2 + + application + com.vaadin.demo.HelloWorld + + + text/html + view + + + HelloWorld + HelloWorld + + + + AddressBookPortlet + Address Book + com.vaadin.terminal.gwt.server.ApplicationPortlet2 + + application + com.vaadin.demo.tutorial.addressbook.AddressBookApplication + + + text/html + view + + + Address Book + Address Book + + + + + CalcPortlet + Calc + com.vaadin.terminal.gwt.server.ApplicationPortlet2 + + application + com.vaadin.demo.Calc + + + text/html + view + + + Calc + Calc + + + + ChatServletPortlet + Vaadin ChatServlet + com.vaadin.terminal.gwt.server.ApplicationPortlet + + application + chat + + + + widgetset + com.vaadin.demo.reservation.gwt.ReservationWidgetSet + + + text/html + view + edit + help + + + ChatServlet + ChatServlet + + + + administrator + + + guest + + + power-user + + + user + + + + BrowserDemoPortlet + Vaadin BrowserDemo + com.vaadin.terminal.gwt.server.ApplicationPortlet + + application + BrowserDemo + + + style + style=height:650px + + + widgetset + com.vaadin.demo.reservation.gwt.ReservationWidgetSet + + + text/html + view + edit + help + + + BrowserDemo + BrowserDemo + + + + administrator + + + guest + + + power-user + + + user + + + + \ No newline at end of file diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 5fbd45a9f9..fade97005f 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -37,24 +37,28 @@ import com.vaadin.ui.Window; public abstract class AbstractApplicationPortlet extends GenericPortlet { - public static final String ERROR_NO_WINDOW_FOUND = "No window found. Did you remember to setMainWindow()?"; + private static final String ERROR_NO_WINDOW_FOUND = "No window found. Did you remember to setMainWindow()?"; - public static final String THEME_DIRECTORY_PATH = "VAADIN/themes/"; + private static final String THEME_DIRECTORY_PATH = "VAADIN/themes/"; - public static final String WIDGETSET_DIRECTORY_PATH = "VAADIN/widgetsets/"; + private static final String WIDGETSET_DIRECTORY_PATH = "VAADIN/widgetsets/"; - public static final String DEFAULT_WIDGETSET = "com.vaadin.terminal.gwt.DefaultWidgetSet"; + private static final String DEFAULT_WIDGETSET = "com.vaadin.terminal.gwt.DefaultWidgetSet"; - public static final String URL_PARAMETER_REPAINT_ALL = "repaintAll"; + private static final String DEFAULT_THEME_NAME = "reindeer"; + + private static final String URL_PARAMETER_REPAINT_ALL = "repaintAll"; - public static final String URL_PARAMETER_RESTART_APPLICATION = "restartApplication"; + private static final String URL_PARAMETER_RESTART_APPLICATION = "restartApplication"; - public static final String URL_PARAMETER_CLOSE_APPLICATION = "closeApplication"; + private static final String URL_PARAMETER_CLOSE_APPLICATION = "closeApplication"; - public static final int DEFAULT_BUFFER_SIZE = 32 * 1024; + private static final int DEFAULT_BUFFER_SIZE = 32 * 1024; // TODO Close application when portlet window is closed + // TODO What happens when the portlet window is resized? + private Properties applicationProperties; @Override @@ -110,14 +114,15 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { private boolean isStaticResourceRequest(ResourceRequest request) { String resourceID = request.getResourceID(); - if (resourceID != null && resourceID.startsWith("/VAADIN/")) { + if (resourceID != null && !resourceID.startsWith("/VAADIN/")) { return true; } return false; } private boolean isUIDLRequest(ResourceRequest request) { - return request.getResourceID().equals("UIDL"); + return request.getResourceID() != null + && request.getResourceID().equals("UIDL"); } private boolean isFileUploadRequest(ActionRequest request) { @@ -126,7 +131,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { protected void handleRequest(PortletRequest request, PortletResponse response) throws PortletException, IOException { - System.out.println("AbstractApplicationPortlet.handleRequest()"); + System.out.println("AbstractApplicationPortlet.handleRequest() " + System.currentTimeMillis()); RequestType requestType = getRequestType(request); @@ -233,39 +238,34 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { } } - // TODO Vaadin resources cannot be loaded, try to load other resources using the portlet context - @Deprecated + // TODO Vaadin resources cannot be loaded, try to load other resources using + // the portlet context + private void serveStaticResources(ResourceRequest request, ResourceResponse response) throws IOException, PortletException { - // Currently, we can only provide VAADIN content final String resourceID = request.getResourceID(); - if (resourceID.startsWith("/VAADIN/")) { - // Strip leading "/" - // final String filename = resourceID.substri - final PortletContext pc = getPortletContext(); - - System.out.println("Trying to load resource [" + resourceID + "]"); - - InputStream is = pc.getResourceAsStream(resourceID); - if (is != null) { - final String mimetype = pc.getMimeType(resourceID); - if (mimetype != null) { - response.setContentType(mimetype); - } - final OutputStream os = response.getPortletOutputStream(); - final byte buffer[] = new byte[DEFAULT_BUFFER_SIZE]; - int bytes; - while ((bytes = is.read(buffer)) >= 0) { - os.write(buffer, 0, bytes); - } - return; - } - } + final PortletContext pc = getPortletContext(); + + System.out.println("Trying to load resource [" + resourceID + "]"); + InputStream is = pc.getResourceAsStream(resourceID); + if (is != null) { + final String mimetype = pc.getMimeType(resourceID); + if (mimetype != null) { + response.setContentType(mimetype); + } + final OutputStream os = response.getPortletOutputStream(); + final byte buffer[] = new byte[DEFAULT_BUFFER_SIZE]; + int bytes; + while ((bytes = is.read(buffer)) >= 0) { + os.write(buffer, 0, bytes); + } + } else { System.err.println("Requested resource [" + resourceID + "] could not be found"); response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer .toString(HttpServletResponse.SC_NOT_FOUND)); + } } @Override @@ -435,11 +435,13 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { response.getPortletOutputStream(), "UTF-8")); ; - // TODO Make the widgetset URL creation more configurable + // TODO The widgetset URL is currently hard-corded for LifeRay - String widgetsetURL = "/html/VAADIN/widgetsets/" + DEFAULT_WIDGETSET + String widgetsetURL = "/html/" + WIDGETSET_DIRECTORY_PATH + DEFAULT_WIDGETSET + "/" + DEFAULT_WIDGETSET + ".nocache.js?" + new Date().getTime(); + + String themeURI = "/html/" + THEME_DIRECTORY_PATH + DEFAULT_THEME_NAME; page.write("\n"); - // TODO Add custom theme + + //if (themeName != null) { + // Custom theme's stylesheet, load only once, in different + // script + // tag to be dominate styles injected by widget + // set + page.write("\n"); + //} + // TODO Warn if widgetset has not been loaded after 15 seconds /*- Add classnames; @@ -496,7 +515,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { } // TODO Add support for flexible theme names String themeClass = "v-theme-" - + "reindeer".replaceAll("[^a-zA-Z0-9]", ""); + + DEFAULT_THEME_NAME.replaceAll("[^a-zA-Z0-9]", ""); String classNames = "v-app v-app-loading " + themeClass + " " + appClass; diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index 07bbac7922..dd7de4b2b7 100644 --- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -79,6 +79,9 @@ import com.vaadin.ui.Upload.UploadException; @SuppressWarnings("serial") public class CommunicationManager implements Paintable.RepaintRequestListener, Serializable { + + // FIXME Create an abstract class with custom Request/Response/Session interfaces, then create + // subclasses for servlets and portlets. private static String GET_PARAM_REPAINT_ALL = "repaintAll"; diff --git a/src/com/vaadin/terminal/gwt/server/WebBrowser.java b/src/com/vaadin/terminal/gwt/server/WebBrowser.java index f7bba2f3ec..09d34c30b5 100644 --- a/src/com/vaadin/terminal/gwt/server/WebBrowser.java +++ b/src/com/vaadin/terminal/gwt/server/WebBrowser.java @@ -77,6 +77,7 @@ public class WebBrowser implements Terminal { } } + // TODO: This method depends on the Portlet API. void updateBrowserProperties(PortletRequest request) { locale = request.getLocale(); address = null;