diff options
author | John Ahlroos <john@vaadin.com> | 2012-09-05 09:00:30 +0300 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2012-09-05 09:00:30 +0300 |
commit | 025d8eae13bc3473b676ff1a534b28b5e812017d (patch) | |
tree | ddab820ea43cbef3fc0c25439a726fe8be5a9897 /server | |
parent | e75e0db87de2b6011fce4406b9924b991f88ce67 (diff) | |
parent | c14171d1344f1360ae4a95cd9494ab2829d439d4 (diff) | |
download | vaadin-framework-025d8eae13bc3473b676ff1a534b28b5e812017d.tar.gz vaadin-framework-025d8eae13bc3473b676ff1a534b28b5e812017d.zip |
Merge branch 'master' into layoutgraph
Diffstat (limited to 'server')
33 files changed, 332 insertions, 350 deletions
diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java index 7af5852512..e4e49391bb 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/Application.java @@ -69,12 +69,12 @@ import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedRequest.BrowserDetails; import com.vaadin.server.WrappedResponse; import com.vaadin.shared.ui.ui.UIConstants; -import com.vaadin.tools.ReflectTools; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractField; import com.vaadin.ui.Table; import com.vaadin.ui.UI; import com.vaadin.ui.Window; +import com.vaadin.util.ReflectTools; /** * <p> @@ -250,6 +250,7 @@ public class Application implements Terminal.ErrorListener, Serializable { // initialized return null; } else { + UI.setCurrent(uiInstance); return uiInstance; } } @@ -673,18 +674,20 @@ public class Application implements Terminal.ErrorListener, Serializable { * This event is sent each time a window is removed from the application * with {@link com.vaadin.Application#removeWindow(Window)}. */ - public class WindowDetachEvent extends EventObject { + public static class WindowDetachEvent extends EventObject { private final Window window; /** * Creates a event. * + * @param application + * the application to which the detached window belonged. * @param window * the Detached window. */ - public WindowDetachEvent(Window window) { - super(Application.this); + public WindowDetachEvent(Application application, Window window) { + super(application); this.window = window; } @@ -713,18 +716,20 @@ public class Application implements Terminal.ErrorListener, Serializable { * This event is sent each time a window is attached tothe application with * {@link com.vaadin.Application#addWindow(Window)}. */ - public class WindowAttachEvent extends EventObject { + public static class WindowAttachEvent extends EventObject { private final Window window; /** * Creates a event. * + * @param application + * the application to which the detached window belonged. * @param window * the Attached window. */ - public WindowAttachEvent(Window window) { - super(Application.this); + public WindowAttachEvent(Application application, Window window) { + super(application); this.window = window; } diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java index d79697f548..9fe99610b2 100644 --- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java +++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java @@ -29,10 +29,10 @@ import com.vaadin.data.Item; import com.vaadin.data.Property; import com.vaadin.data.Validator.InvalidValueException; import com.vaadin.data.util.TransactionalPropertyWrapper; -import com.vaadin.tools.ReflectTools; import com.vaadin.ui.DefaultFieldFactory; import com.vaadin.ui.Field; import com.vaadin.ui.Form; +import com.vaadin.util.ReflectTools; /** * FieldGroup provides an easy way of binding fields to data and handling diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java index 7a63e8c6c2..1b479a21d8 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java @@ -661,7 +661,8 @@ public class SQLContainer implements Container, Container.Filterable, throw new IndexOutOfBoundsException("Index is negative! index=" + index); } - + // make sure the size field is valid + updateCount(); if (index < size) { if (itemIndexes.keySet().contains(index)) { return itemIndexes.get(index); @@ -671,7 +672,9 @@ public class SQLContainer implements Container, Container.Filterable, } else { // The index is in the added items int offset = index - size; - return addedItems.get(offset).getId(); + // TODO this is very inefficient if looping - should improve + // getItemIds(int, int) + return getFilteredAddedItems().get(offset).getId(); } } @@ -694,7 +697,12 @@ public class SQLContainer implements Container, Container.Filterable, @Override public Object nextItemId(Object itemId) { - return getIdByIndex(indexOfId(itemId) + 1); + int index = indexOfId(itemId) + 1; + try { + return getIdByIndex(index); + } catch (IndexOutOfBoundsException e) { + return null; + } } /* diff --git a/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java b/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java index a6a1a5a8fb..8a3dabbf0e 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java @@ -678,7 +678,7 @@ public class TableQuery implements QueryDelegate, /** * Simple RowIdChangeEvent implementation. */ - public class RowIdChangeEvent extends EventObject implements + public static class RowIdChangeEvent extends EventObject implements QueryDelegate.RowIdChangeEvent { private final RowId oldId; private final RowId newId; diff --git a/server/src/com/vaadin/event/FieldEvents.java b/server/src/com/vaadin/event/FieldEvents.java index 10df08291e..1a1bc95305 100644 --- a/server/src/com/vaadin/event/FieldEvents.java +++ b/server/src/com/vaadin/event/FieldEvents.java @@ -21,12 +21,12 @@ import java.lang.reflect.Method; import com.vaadin.shared.EventId; import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc; -import com.vaadin.tools.ReflectTools; import com.vaadin.ui.Component; import com.vaadin.ui.Component.Event; import com.vaadin.ui.Field; import com.vaadin.ui.Field.ValueChangeEvent; import com.vaadin.ui.TextField; +import com.vaadin.util.ReflectTools; /** * Interface that serves as a wrapper for {@link Field} related events. @@ -144,7 +144,7 @@ public interface FieldEvents { * @since 6.2 */ @SuppressWarnings("serial") - public class FocusEvent extends Component.Event { + public static class FocusEvent extends Component.Event { /** * Identifier for event that can be used in {@link EventRouter} @@ -184,7 +184,7 @@ public interface FieldEvents { * @since 6.2 */ @SuppressWarnings("serial") - public class BlurEvent extends Component.Event { + public static class BlurEvent extends Component.Event { /** * Identifier for event that can be used in {@link EventRouter} @@ -243,6 +243,7 @@ public interface FieldEvents { * @since 6.5 */ public static abstract class TextChangeEvent extends Component.Event { + public TextChangeEvent(Component source) { super(source); } diff --git a/server/src/com/vaadin/event/LayoutEvents.java b/server/src/com/vaadin/event/LayoutEvents.java index 7f88ddc640..c113ff1595 100644 --- a/server/src/com/vaadin/event/LayoutEvents.java +++ b/server/src/com/vaadin/event/LayoutEvents.java @@ -21,9 +21,9 @@ import java.lang.reflect.Method; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.shared.Connector; import com.vaadin.shared.MouseEventDetails; -import com.vaadin.tools.ReflectTools; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; +import com.vaadin.util.ReflectTools; public interface LayoutEvents { diff --git a/server/src/com/vaadin/event/MouseEvents.java b/server/src/com/vaadin/event/MouseEvents.java index 0fe9902b2e..e287055c2b 100644 --- a/server/src/com/vaadin/event/MouseEvents.java +++ b/server/src/com/vaadin/event/MouseEvents.java @@ -19,8 +19,8 @@ package com.vaadin.event; import java.lang.reflect.Method; import com.vaadin.shared.MouseEventDetails; -import com.vaadin.tools.ReflectTools; import com.vaadin.ui.Component; +import com.vaadin.util.ReflectTools; /** * Interface that serves as a wrapper for mouse related events. @@ -43,7 +43,7 @@ public interface MouseEvents { * @see ClickListener * @since 6.2 */ - public class ClickEvent extends Component.Event { + public static class ClickEvent extends Component.Event { public static final int BUTTON_LEFT = MouseEventDetails.BUTTON_LEFT; public static final int BUTTON_MIDDLE = MouseEventDetails.BUTTON_MIDDLE; public static final int BUTTON_RIGHT = MouseEventDetails.BUTTON_RIGHT; @@ -202,7 +202,7 @@ public interface MouseEvents { * @author Vaadin Ltd. * @since 6.2 */ - public class DoubleClickEvent extends Component.Event { + public static class DoubleClickEvent extends Component.Event { public DoubleClickEvent(Component source) { super(source); diff --git a/server/src/com/vaadin/server/AddonContext.java b/server/src/com/vaadin/server/AddonContext.java index b3cd5ea226..c9f2ac07eb 100644 --- a/server/src/com/vaadin/server/AddonContext.java +++ b/server/src/com/vaadin/server/AddonContext.java @@ -24,7 +24,7 @@ import java.util.ServiceLoader; import com.vaadin.Application; import com.vaadin.event.EventRouter; -import com.vaadin.tools.ReflectTools; +import com.vaadin.util.ReflectTools; /** * Point of entry for add-ons for integrating into various aspects of the diff --git a/server/src/com/vaadin/server/DeploymentConfiguration.java b/server/src/com/vaadin/server/DeploymentConfiguration.java index acfba405e6..6150edbafb 100644 --- a/server/src/com/vaadin/server/DeploymentConfiguration.java +++ b/server/src/com/vaadin/server/DeploymentConfiguration.java @@ -32,14 +32,19 @@ import javax.servlet.ServletContext; * @since 7.0 */ public interface DeploymentConfiguration extends Serializable { - /** - * Gets the base URL of the location of Vaadin's static files. + * Return the URL from where static files, e.g. the widgetset and the theme, + * are served. In a standard configuration the VAADIN folder inside the + * returned folder is what is used for widgetsets and themes. + * + * The returned folder is usually the same as the context path and + * independent of the application. * * @param request * the request for which the location should be determined * - * @return a string with the base URL for static files + * @return The location of static resources (should contain the VAADIN + * directory). Never ends with a slash (/). */ public String getStaticFileLocation(WrappedRequest request); diff --git a/server/src/com/vaadin/server/JavaScriptCallbackHelper.java b/server/src/com/vaadin/server/JavaScriptCallbackHelper.java index 19b19ce824..d17ae71114 100644 --- a/server/src/com/vaadin/server/JavaScriptCallbackHelper.java +++ b/server/src/com/vaadin/server/JavaScriptCallbackHelper.java @@ -27,10 +27,10 @@ import java.util.Set; import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; import com.vaadin.shared.JavaScriptConnectorState; -import com.vaadin.tools.ReflectTools; import com.vaadin.ui.AbstractJavaScriptComponent; import com.vaadin.ui.JavaScript.JavaScriptCallbackRpc; import com.vaadin.ui.JavaScriptFunction; +import com.vaadin.util.ReflectTools; /** * Internal helper class used to implement functionality common to diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index da172ed837..015c6c907f 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -28,10 +28,10 @@ import com.vaadin.server.WrappedRequest.BrowserDetails; import com.vaadin.shared.ui.BorderStyle; import com.vaadin.shared.ui.ui.PageClientRpc; import com.vaadin.shared.ui.ui.UIConstants; -import com.vaadin.tools.ReflectTools; import com.vaadin.ui.JavaScript; import com.vaadin.ui.Notification; import com.vaadin.ui.UI; +import com.vaadin.util.ReflectTools; public class Page implements Serializable { @@ -54,7 +54,7 @@ public class Page implements Serializable { /** * Event that is fired when a browser window containing a uI is resized. */ - public class BrowserWindowResizeEvent extends EventObject { + public static class BrowserWindowResizeEvent extends EventObject { private final int width; private final int height; @@ -233,7 +233,7 @@ public class Page implements Serializable { /** * Event fired when uri fragment changes. */ - public class FragmentChangedEvent extends EventObject { + public static class FragmentChangedEvent extends EventObject { /** * The new uri fragment diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index 25512e9237..4d6d7b84f0 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -66,11 +66,94 @@ import com.vaadin.ui.UI; * * @author peholmst */ -public class VaadinPortlet extends GenericPortlet implements - Constants { +public class VaadinPortlet extends GenericPortlet implements Constants { public static final String RESOURCE_URL_ID = "APP"; + public static class PortletDeploymentConfiguration extends + AbstractDeploymentConfiguration { + private final VaadinPortlet portlet; + + public PortletDeploymentConfiguration(VaadinPortlet portlet, + Properties applicationProperties) { + super(portlet.getClass(), applicationProperties); + this.portlet = portlet; + } + + protected VaadinPortlet getPortlet() { + return portlet; + } + + @Override + public String getConfiguredWidgetset(WrappedRequest request) { + + String widgetset = getApplicationOrSystemProperty( + PARAMETER_WIDGETSET, null); + + if (widgetset == null) { + // If no widgetset defined for the application, check the + // portal property + widgetset = WrappedPortletRequest.cast(request) + .getPortalProperty(PORTAL_PARAMETER_VAADIN_WIDGETSET); + } + + if (widgetset == null) { + // If no widgetset defined for the portal, use the default + widgetset = DEFAULT_WIDGETSET; + } + + return widgetset; + } + + @Override + public String getConfiguredTheme(WrappedRequest request) { + + // is the default theme defined by the portal? + String themeName = WrappedPortletRequest.cast(request) + .getPortalProperty(Constants.PORTAL_PARAMETER_VAADIN_THEME); + + if (themeName == null) { + // no, using the default theme defined by Vaadin + themeName = DEFAULT_THEME_NAME; + } + + return themeName; + } + + @Override + public boolean isStandalone(WrappedRequest request) { + return false; + } + + @Override + public String getStaticFileLocation(WrappedRequest request) { + String staticFileLocation = WrappedPortletRequest.cast(request) + .getPortalProperty( + Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH); + if (staticFileLocation != null) { + // remove trailing slash if any + while (staticFileLocation.endsWith(".")) { + staticFileLocation = staticFileLocation.substring(0, + staticFileLocation.length() - 1); + } + return staticFileLocation; + } else { + // default for Liferay + return "/html"; + } + } + + @Override + public String getMimeType(String resourceName) { + return getPortlet().getPortletContext().getMimeType(resourceName); + } + + @Override + public SystemMessages getSystemMessages() { + return ServletPortletHelper.DEFAULT_SYSTEM_MESSAGES; + } + } + public static class WrappedHttpAndPortletRequest extends WrappedPortletRequest { @@ -177,8 +260,7 @@ public class VaadinPortlet extends GenericPortlet implements private final VaadinPortlet portlet; - public AbstractApplicationPortletWrapper( - VaadinPortlet portlet) { + public AbstractApplicationPortletWrapper(VaadinPortlet portlet) { this.portlet = portlet; } @@ -236,101 +318,17 @@ public class VaadinPortlet extends GenericPortlet implements config.getInitParameter(name)); } - deploymentConfiguration = new AbstractDeploymentConfiguration( - getClass(), applicationProperties) { - @Override - public String getConfiguredWidgetset(WrappedRequest request) { - - String widgetset = getApplicationOrSystemProperty( - PARAMETER_WIDGETSET, null); - - if (widgetset == null) { - // If no widgetset defined for the application, check the - // portal property - widgetset = WrappedPortletRequest.cast(request) - .getPortalProperty( - PORTAL_PARAMETER_VAADIN_WIDGETSET); - } - - if (widgetset == null) { - // If no widgetset defined for the portal, use the default - widgetset = DEFAULT_WIDGETSET; - } - - return widgetset; - } - - @Override - public String getConfiguredTheme(WrappedRequest request) { - - // is the default theme defined by the portal? - String themeName = WrappedPortletRequest.cast(request) - .getPortalProperty( - Constants.PORTAL_PARAMETER_VAADIN_THEME); - - if (themeName == null) { - // no, using the default theme defined by Vaadin - themeName = DEFAULT_THEME_NAME; - } - - return themeName; - } - - @Override - public boolean isStandalone(WrappedRequest request) { - return false; - } - - /* - * (non-Javadoc) - * - * @see - * com.vaadin.terminal.DeploymentConfiguration#getStaticFileLocation - * (com.vaadin.terminal.WrappedRequest) - * - * Return the URL from where static files, e.g. the widgetset and - * the theme, are served. In a standard configuration the VAADIN - * folder inside the returned folder is what is used for widgetsets - * and themes. - * - * @return The location of static resources (inside which there - * should be a VAADIN directory). Does not end with a slash (/). - */ - - @Override - public String getStaticFileLocation(WrappedRequest request) { - String staticFileLocation = WrappedPortletRequest - .cast(request) - .getPortalProperty( - Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH); - if (staticFileLocation != null) { - // remove trailing slash if any - while (staticFileLocation.endsWith(".")) { - staticFileLocation = staticFileLocation.substring(0, - staticFileLocation.length() - 1); - } - return staticFileLocation; - } else { - // default for Liferay - return "/html"; - } - } - - @Override - public String getMimeType(String resourceName) { - return getPortletContext().getMimeType(resourceName); - } - - @Override - public SystemMessages getSystemMessages() { - return VaadinPortlet.this.getSystemMessages(); - } - }; + deploymentConfiguration = createDeploymentConfiguration(applicationProperties); addonContext = new AddonContext(deploymentConfiguration); addonContext.init(); } + protected DeploymentConfiguration createDeploymentConfiguration( + Properties applicationProperties) { + return new PortletDeploymentConfiguration(this, applicationProperties); + } + @Override public void destroy() { super.destroy(); @@ -913,15 +911,6 @@ public class VaadinPortlet extends GenericPortlet implements } } - /** - * Get system messages from the current application class - * - * @return - */ - protected SystemMessages getSystemMessages() { - return ServletPortletHelper.DEFAULT_SYSTEM_MESSAGES; - } - private void handleServiceException(WrappedPortletRequest request, WrappedPortletResponse response, Application application, Throwable e) throws IOException, PortletException { @@ -930,7 +919,8 @@ public class VaadinPortlet extends GenericPortlet implements // if this was an UIDL request, response UIDL back to client if (getRequestType(request) == RequestType.UIDL) { - SystemMessages ci = getSystemMessages(); + SystemMessages ci = getDeploymentConfiguration() + .getSystemMessages(); criticalNotification(request, response, ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), null, ci.getInternalErrorURL()); diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 0766d46e93..a10ad965c5 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -54,6 +54,90 @@ import com.vaadin.ui.UI; @SuppressWarnings("serial") public class VaadinServlet extends HttpServlet implements Constants { + public static class ServletDeploymentConfiguration extends + AbstractDeploymentConfiguration { + private final VaadinServlet servlet; + + public ServletDeploymentConfiguration(VaadinServlet servlet, + Properties applicationProperties) { + super(servlet.getClass(), applicationProperties); + this.servlet = servlet; + } + + protected VaadinServlet getServlet() { + return servlet; + } + + @Override + public String getStaticFileLocation(WrappedRequest request) { + HttpServletRequest servletRequest = WrappedHttpServletRequest + .cast(request); + String staticFileLocation; + // if property is defined in configurations, use that + staticFileLocation = getApplicationOrSystemProperty( + PARAMETER_VAADIN_RESOURCES, null); + if (staticFileLocation != null) { + return staticFileLocation; + } + + // the last (but most common) option is to generate default location + // from request + + // if context is specified add it to widgetsetUrl + String ctxPath = servletRequest.getContextPath(); + + // FIXME: ctxPath.length() == 0 condition is probably unnecessary + // and + // might even be wrong. + + if (ctxPath.length() == 0 + && request + .getAttribute("javax.servlet.include.context_path") != null) { + // include request (e.g portlet), get context path from + // attribute + ctxPath = (String) request + .getAttribute("javax.servlet.include.context_path"); + } + + // Remove heading and trailing slashes from the context path + ctxPath = removeHeadingOrTrailing(ctxPath, "/"); + + if (ctxPath.equals("")) { + return ""; + } else { + return "/" + ctxPath; + } + } + + @Override + public String getConfiguredWidgetset(WrappedRequest request) { + return getApplicationOrSystemProperty( + VaadinServlet.PARAMETER_WIDGETSET, + VaadinServlet.DEFAULT_WIDGETSET); + } + + @Override + public String getConfiguredTheme(WrappedRequest request) { + // Use the default + return VaadinServlet.getDefaultTheme(); + } + + @Override + public boolean isStandalone(WrappedRequest request) { + return true; + } + + @Override + public String getMimeType(String resourceName) { + return getServlet().getServletContext().getMimeType(resourceName); + } + + @Override + public SystemMessages getSystemMessages() { + return ServletPortletHelper.DEFAULT_SYSTEM_MESSAGES; + } + } + private static class AbstractApplicationServletWrapper implements Callback { private final VaadinServlet servlet; @@ -116,50 +200,17 @@ public class VaadinServlet extends HttpServlet implements Constants { servletConfig.getInitParameter(name)); } - deploymentConfiguration = new AbstractDeploymentConfiguration( - getClass(), applicationProperties) { - - @Override - public String getStaticFileLocation(WrappedRequest request) { - HttpServletRequest servletRequest = WrappedHttpServletRequest - .cast(request); - return VaadinServlet.this - .getStaticFilesLocation(servletRequest); - } - - @Override - public String getConfiguredWidgetset(WrappedRequest request) { - return getApplicationOrSystemProperty( - VaadinServlet.PARAMETER_WIDGETSET, - VaadinServlet.DEFAULT_WIDGETSET); - } - - @Override - public String getConfiguredTheme(WrappedRequest request) { - // Use the default - return VaadinServlet.getDefaultTheme(); - } - - @Override - public boolean isStandalone(WrappedRequest request) { - return true; - } - - @Override - public String getMimeType(String resourceName) { - return getServletContext().getMimeType(resourceName); - } - - @Override - public SystemMessages getSystemMessages() { - return VaadinServlet.this.getSystemMessages(); - } - }; + deploymentConfiguration = createDeploymentConfiguration(applicationProperties); addonContext = new AddonContext(deploymentConfiguration); addonContext.init(); } + protected ServletDeploymentConfiguration createDeploymentConfiguration( + Properties applicationProperties) { + return new ServletDeploymentConfiguration(this, applicationProperties); + } + @Override public void destroy() { super.destroy(); @@ -430,10 +481,12 @@ public class VaadinServlet extends HttpServlet implements Constants { // This can be removed if cookieless mode (#3228) is supported if (request.getRequestedSessionId() == null) { // User has cookies disabled - criticalNotification(request, response, getSystemMessages() - .getCookiesDisabledCaption(), getSystemMessages() - .getCookiesDisabledMessage(), null, getSystemMessages() - .getCookiesDisabledURL()); + SystemMessages systemMessages = getDeploymentConfiguration() + .getSystemMessages(); + criticalNotification(request, response, + systemMessages.getCookiesDisabledCaption(), + systemMessages.getCookiesDisabledMessage(), null, + systemMessages.getCookiesDisabledURL()); return false; } } @@ -695,7 +748,8 @@ public class VaadinServlet extends HttpServlet implements Constants { Throwable e) throws IOException, ServletException { // if this was an UIDL request, response UIDL back to client if (getRequestType(request) == RequestType.UIDL) { - SystemMessages ci = getSystemMessages(); + SystemMessages ci = getDeploymentConfiguration() + .getSystemMessages(); criticalNotification(request, response, ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), null, ci.getInternalErrorURL()); @@ -758,7 +812,8 @@ public class VaadinServlet extends HttpServlet implements Constants { } try { - SystemMessages ci = getSystemMessages(); + SystemMessages ci = getDeploymentConfiguration() + .getSystemMessages(); if (getRequestType(request) != RequestType.UIDL) { // 'plain' http req - e.g. browser reload; // just go ahead redirect the browser @@ -800,7 +855,8 @@ public class VaadinServlet extends HttpServlet implements Constants { } try { - SystemMessages ci = getSystemMessages(); + SystemMessages ci = getDeploymentConfiguration() + .getSystemMessages(); if (getRequestType(request) != RequestType.UIDL) { // 'plain' http req - e.g. browser reload; // just go ahead redirect the browser @@ -1185,77 +1241,6 @@ public class VaadinServlet extends HttpServlet implements Constants { } /** - * Get system messages - * - * @return - */ - protected SystemMessages getSystemMessages() { - return ServletPortletHelper.DEFAULT_SYSTEM_MESSAGES; - } - - /** - * Return the URL from where static files, e.g. the widgetset and the theme, - * are served. In a standard configuration the VAADIN folder inside the - * returned folder is what is used for widgetsets and themes. - * - * The returned folder is usually the same as the context path and - * independent of the application. - * - * @param request - * @return The location of static resources (should contain the VAADIN - * directory). Never ends with a slash (/). - */ - protected String getStaticFilesLocation(HttpServletRequest request) { - - return getWebApplicationsStaticFileLocation(request); - } - - /** - * The default method to fetch static files location (URL). This method does - * not check for request attribute {@value #REQUEST_VAADIN_STATIC_FILE_PATH} - * - * @param request - * @return - */ - private String getWebApplicationsStaticFileLocation( - HttpServletRequest request) { - String staticFileLocation; - // if property is defined in configurations, use that - staticFileLocation = getDeploymentConfiguration() - .getApplicationOrSystemProperty(PARAMETER_VAADIN_RESOURCES, - null); - if (staticFileLocation != null) { - return staticFileLocation; - } - - // the last (but most common) option is to generate default location - // from request - - // if context is specified add it to widgetsetUrl - String ctxPath = request.getContextPath(); - - // FIXME: ctxPath.length() == 0 condition is probably unnecessary and - // might even be wrong. - - if (ctxPath.length() == 0 - && request.getAttribute("javax.servlet.include.context_path") != null) { - // include request (e.g portlet), get context path from - // attribute - ctxPath = (String) request - .getAttribute("javax.servlet.include.context_path"); - } - - // Remove heading and trailing slashes from the context path - ctxPath = removeHeadingOrTrailing(ctxPath, "/"); - - if (ctxPath.equals("")) { - return ""; - } else { - return "/" + ctxPath; - } - } - - /** * Remove any heading or trailing "what" from the "string". * * @param string diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 97883b780f..37ca9f1a03 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -41,7 +41,7 @@ import com.vaadin.server.Terminal; import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ComponentState; import com.vaadin.shared.ui.ComponentStateUtil; -import com.vaadin.tools.ReflectTools; +import com.vaadin.util.ReflectTools; /** * An abstract class that defines default implementation for the diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 2fc3bf4080..2f420b9286 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -19,6 +19,7 @@ package com.vaadin.ui; import java.io.Serializable; import java.util.Collection; import java.util.Collections; +import java.util.EventObject; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -1612,7 +1613,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements protected void firePropertySetChange() { if (propertySetEventListeners != null && !propertySetEventListeners.isEmpty()) { - final Container.PropertySetChangeEvent event = new PropertySetChangeEvent(); + final Container.PropertySetChangeEvent event = new PropertySetChangeEvent( + this); final Object[] listeners = propertySetEventListeners.toArray(); for (int i = 0; i < listeners.length; i++) { ((Container.PropertySetChangeListener) listeners[i]) @@ -1627,7 +1629,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements */ protected void fireItemSetChange() { if (itemSetEventListeners != null && !itemSetEventListeners.isEmpty()) { - final Container.ItemSetChangeEvent event = new ItemSetChangeEvent(); + final Container.ItemSetChangeEvent event = new ItemSetChangeEvent( + this); final Object[] listeners = itemSetEventListeners.toArray(); for (int i = 0; i < listeners.length; i++) { ((Container.ItemSetChangeListener) listeners[i]) @@ -1640,8 +1643,12 @@ public abstract class AbstractSelect extends AbstractField<Object> implements /** * Implementation of item set change event. */ - private class ItemSetChangeEvent implements Serializable, - Container.ItemSetChangeEvent { + private static class ItemSetChangeEvent extends EventObject implements + Serializable, Container.ItemSetChangeEvent { + + private ItemSetChangeEvent(Container source) { + super(source); + } /** * Gets the Property where the event occurred. @@ -1650,7 +1657,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements */ @Override public Container getContainer() { - return AbstractSelect.this; + return (Container) getSource(); } } @@ -1658,9 +1665,13 @@ public abstract class AbstractSelect extends AbstractField<Object> implements /** * Implementation of property set change event. */ - private class PropertySetChangeEvent implements + private static class PropertySetChangeEvent extends EventObject implements Container.PropertySetChangeEvent, Serializable { + private PropertySetChangeEvent(Container source) { + super(source); + } + /** * Retrieves the Container whose contents have been modified. * @@ -1668,7 +1679,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements */ @Override public Container getContainer() { - return AbstractSelect.this; + return (Container) getSource(); } } diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index c5df57b36f..dd6ff50efb 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -28,7 +28,7 @@ import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelRpc; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState.SplitterState; -import com.vaadin.tools.ReflectTools; +import com.vaadin.util.ReflectTools; /** * AbstractSplitPanel. @@ -392,8 +392,8 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * Allowed units are UNITS_PERCENTAGE and UNITS_PIXELS */ public void setMaxSplitPosition(float pos, Unit unit) { - setSplitPositionLimits(getSplitterState().minPosition, posMinUnit, - pos, unit); + setSplitPositionLimits(getSplitterState().minPosition, posMinUnit, pos, + unit); } /** @@ -492,7 +492,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { public void splitterClick(SplitterClickEvent event); } - public class SplitterClickEvent extends ClickEvent { + public static class SplitterClickEvent extends ClickEvent { public SplitterClickEvent(Component source, MouseEventDetails mouseEventDetails) { diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 0cb74dae6d..3dd2b4dae8 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -570,7 +570,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements return textChangeEventTimeout; } - public class TextChangeEventImpl extends TextChangeEvent { + public static class TextChangeEventImpl extends TextChangeEvent { private String curText; private int cursorPosition; diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index bbed7d540f..02b7689259 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -33,8 +33,8 @@ import com.vaadin.event.ShortcutListener; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.button.ButtonServerRpc; import com.vaadin.shared.ui.button.ButtonState; -import com.vaadin.tools.ReflectTools; import com.vaadin.ui.Component.Focusable; +import com.vaadin.util.ReflectTools; /** * A generic button component. @@ -108,7 +108,7 @@ public class Button extends AbstractComponent implements * @author Vaadin Ltd. * @since 3.0 */ - public class ClickEvent extends Component.Event { + public static class ClickEvent extends Component.Event { private final MouseEventDetails details; diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index 01033ff560..5bd1d53b86 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -670,7 +670,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * @see Component.Listener */ @SuppressWarnings("serial") - public class Event extends EventObject { + public static class Event extends EventObject { /** * Constructs a new event with the specified source component. @@ -860,7 +860,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * </p> */ @SuppressWarnings("serial") - public class ErrorEvent extends Event { + public static class ErrorEvent extends Event { private final ErrorMessage message; diff --git a/server/src/com/vaadin/ui/ComponentContainer.java b/server/src/com/vaadin/ui/ComponentContainer.java index cee6d7300b..50a6e7e148 100644 --- a/server/src/com/vaadin/ui/ComponentContainer.java +++ b/server/src/com/vaadin/ui/ComponentContainer.java @@ -174,7 +174,7 @@ public interface ComponentContainer extends HasComponents { * Component attach event sent when a component is attached to container. */ @SuppressWarnings("serial") - public class ComponentAttachEvent extends Component.Event { + public static class ComponentAttachEvent extends Component.Event { private final Component component; @@ -218,7 +218,7 @@ public interface ComponentContainer extends HasComponents { * Component detach event sent when a component is detached from container. */ @SuppressWarnings("serial") - public class ComponentDetachEvent extends Component.Event { + public static class ComponentDetachEvent extends Component.Event { private final Component component; diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index f9213a66fe..18927077d8 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -108,7 +108,7 @@ public class LoginForm extends CustomComponent { String value = (parameters.get(key))[0]; params.put(key, value); } - LoginEvent event = new LoginEvent(params); + LoginEvent event = new LoginEvent(LoginForm.this, params); fireEvent(event); return true; } @@ -200,12 +200,12 @@ public class LoginForm extends CustomComponent { /** * This event is sent when login form is submitted. */ - public class LoginEvent extends Event { + public static class LoginEvent extends Event { private Map<String, String> params; - private LoginEvent(Map<String, String> params) { - super(LoginForm.this); + private LoginEvent(Component source, Map<String, String> params) { + super(source); this.params = params; } diff --git a/server/src/com/vaadin/ui/PopupView.java b/server/src/com/vaadin/ui/PopupView.java index 8d6d28e121..182e71d6c9 100644 --- a/server/src/com/vaadin/ui/PopupView.java +++ b/server/src/com/vaadin/ui/PopupView.java @@ -20,10 +20,10 @@ import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.LegacyPaint; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; -import com.vaadin.server.LegacyComponent; /** * @@ -421,7 +421,7 @@ public class PopupView extends AbstractComponentContainer implements * event with {@link #getPopupView()}. * */ - public class PopupVisibilityEvent extends Event { + public static class PopupVisibilityEvent extends Event { public PopupVisibilityEvent(PopupView source) { super(source); diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java index eb66de519f..291aea3bd6 100644 --- a/server/src/com/vaadin/ui/TabSheet.java +++ b/server/src/com/vaadin/ui/TabSheet.java @@ -32,11 +32,11 @@ import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.FieldEvents.FocusNotifier; import com.vaadin.server.ErrorMessage; import com.vaadin.server.KeyMapper; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.LegacyPaint; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; -import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.tabsheet.TabsheetBaseConstants; import com.vaadin.shared.ui.tabsheet.TabsheetConstants; import com.vaadin.ui.Component.Focusable; @@ -743,7 +743,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * @author Vaadin Ltd. * @since 3.0 */ - public class SelectedTabChangeEvent extends Component.Event { + public static class SelectedTabChangeEvent extends Component.Event { /** * New instance of selected tab change event diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index 5eb18ee61f..65189fed0c 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -3479,8 +3479,8 @@ public class Table extends AbstractSelect implements Action.Container, * target. */ if (cellStyleGenerator != null) { - String cellStyle = cellStyleGenerator - .getStyle(itemId, columnId); + String cellStyle = cellStyleGenerator.getStyle(this, itemId, + columnId); if (cellStyle != null && !cellStyle.equals("")) { target.addAttribute("style-" + columnIdMap.key(columnId), cellStyle); @@ -3567,7 +3567,7 @@ public class Table extends AbstractSelect implements Action.Container, * to the target. */ if (cellStyleGenerator != null) { - String rowStyle = cellStyleGenerator.getStyle(itemId, null); + String rowStyle = cellStyleGenerator.getStyle(this, itemId, null); if (rowStyle != null && !rowStyle.equals("")) { target.addAttribute("rowstyle", rowStyle); } @@ -4602,6 +4602,8 @@ public class Table extends AbstractSelect implements Action.Container, /** * Called by Table when a cell (and row) is painted. * + * @param source + * the source Table * @param itemId * The itemId of the painted cell * @param propertyId @@ -4610,7 +4612,8 @@ public class Table extends AbstractSelect implements Action.Container, * name will be v-table-cell-content-[style name], or * v-table-row-[style name] for rows) */ - public abstract String getStyle(Object itemId, Object propertyId); + public abstract String getStyle(Table source, Object itemId, + Object propertyId); } @Override diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index 03895a12bb..306d1f18ba 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -56,7 +56,7 @@ import com.vaadin.server.Resource; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.dd.VerticalDropLocation; import com.vaadin.shared.ui.tree.TreeConstants; -import com.vaadin.tools.ReflectTools; +import com.vaadin.util.ReflectTools; /** * Tree component. A Tree can be used to select an item (or multiple items) from @@ -611,7 +611,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } if (itemStyleGenerator != null) { - String stylename = itemStyleGenerator.getStyle(itemId); + String stylename = itemStyleGenerator + .getStyle(this, itemId); if (stylename != null) { target.addAttribute(TreeConstants.ATTRIBUTE_NODE_STYLE, stylename); @@ -1255,12 +1256,14 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, /** * Called by Tree when an item is painted. * + * @param source + * the source Tree * @param itemId * The itemId of the item to be painted * @return The style name to add to this item. (the CSS class name will * be v-tree-node-[style name] */ - public abstract String getStyle(Object itemId); + public abstract String getStyle(Tree source, Object itemId); } // Overriden so javadoc comes from Container.Hierarchical diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 0f914d3947..ee4cb9fd2c 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -49,7 +49,7 @@ import com.vaadin.shared.ui.BorderStyle; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.shared.ui.ui.UIServerRpc; import com.vaadin.shared.ui.ui.UIState; -import com.vaadin.tools.ReflectTools; +import com.vaadin.util.ReflectTools; /** * The topmost component in any component hierarchy. There is one UI for every @@ -691,13 +691,14 @@ public abstract class UI extends AbstractComponentContainer implements if ((application == null) == (this.application == null)) { throw new IllegalStateException("Application has already been set"); } else { + if (application == null) { + detach(); + } this.application = application; } if (application != null) { attach(); - } else { - detach(); } } diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 5c94a4c929..d7a33d742c 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -299,7 +299,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, } } - public class CloseEvent extends Component.Event { + public static class CloseEvent extends Component.Event { /** * @@ -422,7 +422,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * (e.g. the browser window is resized). The frequency may vary across * browsers. */ - public class ResizeEvent extends Component.Event { + public static class ResizeEvent extends Component.Event { /** * diff --git a/server/src/com/vaadin/tools/ReflectTools.java b/server/src/com/vaadin/util/ReflectTools.java index fcfe00564e..285d876e1c 100644 --- a/server/src/com/vaadin/tools/ReflectTools.java +++ b/server/src/com/vaadin/util/ReflectTools.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.tools; +package com.vaadin.util; import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java index 438c40823d..7b3d8a4cf2 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java @@ -1468,7 +1468,12 @@ public class SQLContainerTableQueryTest { container.getContainerProperty(container.getIdByIndex(3), "NAME").getValue()); - Assert.assertNull(container.getIdByIndex(4)); + try { + container.getIdByIndex(4); + Assert.fail("SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); + } catch (IndexOutOfBoundsException e) { + // should throw exception - item is filtered out + } Assert.assertNull(container.nextItemId(container.getIdByIndex(3))); Assert.assertFalse(container.containsId(id2)); diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java index 6649bc16e8..0856b3c08c 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java @@ -2322,8 +2322,13 @@ public class SQLContainerTest { container.getContainerProperty(container.getIdByIndex(3), "NAME").getValue()); - Assert.assertNull(container.getIdByIndex(4)); - Assert.assertNull(container.nextItemId(container.getIdByIndex(3))); + try { + container.getIdByIndex(4); + Assert.fail("SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); + } catch (IndexOutOfBoundsException e) { + // should throw exception - item is filtered out + } + container.nextItemId(container.getIdByIndex(3)); Assert.assertFalse(container.containsId(id2)); Assert.assertFalse(container.getItemIds().contains(id2)); diff --git a/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java b/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java index 3ae41610fa..b936cae1a5 100644 --- a/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java +++ b/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java @@ -5,23 +5,21 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; -import java.util.Enumeration; import java.util.Properties; -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import junit.framework.TestCase; +import com.vaadin.server.VaadinServlet.ServletDeploymentConfiguration; + public class TestAbstractApplicationServletStaticFilesLocation extends TestCase { VaadinServlet servlet; - private Method getStaticFilesLocationMethod; + // private Method getStaticFilesLocationMethod; @Override protected void setUp() throws Exception { @@ -30,53 +28,11 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase servlet = new VaadinServlet(); // Workaround to avoid calling init and creating servlet config - Field f = VaadinServlet.class.getDeclaredField("applicationProperties"); + Field f = VaadinServlet.class + .getDeclaredField("deploymentConfiguration"); f.setAccessible(true); - f.set(servlet, new Properties()); - - getStaticFilesLocationMethod = VaadinServlet.class.getDeclaredMethod( - "getStaticFilesLocation", - new Class[] { javax.servlet.http.HttpServletRequest.class }); - getStaticFilesLocationMethod.setAccessible(true); - - } - - public class DummyServletConfig implements ServletConfig { - - // public DummyServletConfig(Map<String,String> initParameters, ) - @Override - public String getInitParameter(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Enumeration<Object> getInitParameterNames() { - return new Enumeration<Object>() { - - @Override - public boolean hasMoreElements() { - return false; - } - - @Override - public Object nextElement() { - return null; - } - }; - } - - @Override - public ServletContext getServletContext() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getServletName() { - // TODO Auto-generated method stub - return null; - } + f.set(servlet, new ServletDeploymentConfiguration(servlet, + new Properties())); } @@ -122,8 +78,8 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase // Set request into replay mode replay(request); - String location = (String) getStaticFilesLocationMethod.invoke(servlet, - request); + String location = servlet.getDeploymentConfiguration() + .getStaticFileLocation(servlet.createWrappedRequest(request)); return location; } @@ -135,8 +91,8 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase // Set request into replay mode replay(request); - String location = (String) getStaticFilesLocationMethod.invoke(servlet, - request); + String location = servlet.getDeploymentConfiguration() + .getStaticFileLocation(servlet.createWrappedRequest(request)); return location; } diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java index 5dbab8467e..18567b62f0 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java @@ -18,6 +18,9 @@ public class RemoveListenersOnDetach { int numReadOnlyChanges = 0; AbstractField field = new AbstractField() { + final private Application application = new Application() { + + }; private UI uI = new UI() { @Override @@ -25,8 +28,10 @@ public class RemoveListenersOnDetach { } - }; - private Application application = new Application() { + @Override + public Application getApplication() { + return application; + } }; diff --git a/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java b/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java index d58ff28b00..905ddb529b 100644 --- a/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java +++ b/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java @@ -56,8 +56,7 @@ public class UriFragmentManagerTest extends TestCase { navigator.navigateTo("test"); control.replay(); - FragmentChangedEvent event = page.new FragmentChangedEvent(page, - "oldtest"); + FragmentChangedEvent event = new FragmentChangedEvent(page, "oldtest"); manager.fragmentChanged(event); } } |