diff options
author | Leif Åstrand <leif@vaadin.com> | 2011-12-14 17:24:10 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2011-12-14 17:24:10 +0200 |
commit | 453a65cbc49eaa45f3a812c67f0c34987f0a61b5 (patch) | |
tree | af91dbd91699a55d323c55cdb2034b9a7a82f9b3 /src/com/vaadin/terminal/gwt/server/CommunicationManager.java | |
parent | 5c481e25354e23b56fcaa158c14774dc57827b2b (diff) | |
download | vaadin-framework-453a65cbc49eaa45f3a812c67f0c34987f0a61b5.tar.gz vaadin-framework-453a65cbc49eaa45f3a812c67f0c34987f0a61b5.zip |
Move the initialization of AjaxPageHandler to avoid null pointers
Diffstat (limited to 'src/com/vaadin/terminal/gwt/server/CommunicationManager.java')
-rw-r--r-- | src/com/vaadin/terminal/gwt/server/CommunicationManager.java | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index e352d606c1..e660e14a8f 100644 --- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -34,57 +34,6 @@ import com.vaadin.ui.Component; @SuppressWarnings("serial") public class CommunicationManager extends AbstractCommunicationManager { - private final AjaxPageHandler ajaxPageHandler = new AjaxPageHandler() { - @Override - protected String getApplicationId(AjaxPageContext context) { - String appUrl = getAppUri(context); - - String appId = appUrl; - if ("".equals(appUrl)) { - appId = "ROOT"; - } - appId = appId.replaceAll("[^a-zA-Z0-9]", ""); - // Add hashCode to the end, so that it is still (sort of) - // predictable, but indicates that it should not be used in CSS and - // such: - int hashCode = appId.hashCode(); - if (hashCode < 0) { - hashCode = -hashCode; - } - appId = appId + "-" + hashCode; - return appId; - } - - @Override - protected String getAppUri(AjaxPageContext context) { - /* Fetch relative url to application */ - // don't use server and port in uri. It may cause problems with some - // virtual server configurations which lose the server name - Application application = context.getApplication(); - URL url = application.getURL(); - String appUrl = url.getPath(); - if (appUrl.endsWith("/")) { - appUrl = appUrl.substring(0, appUrl.length() - 1); - } - return appUrl; - } - - @Override - public String getThemeName(AjaxPageContext context) { - String themeName = context.getRequest().getParameter( - AbstractApplicationServlet.URL_PARAMETER_THEME); - if (themeName == null) { - themeName = super.getThemeName(context); - } - return themeName; - } - - @Override - protected AbstractCommunicationManager getCommunicationManager() { - return CommunicationManager.this; - } - }; - /** * @deprecated use {@link #CommunicationManager(Application)} instead * @param application @@ -232,7 +181,58 @@ public class CommunicationManager extends AbstractCommunicationManager { } @Override - protected AjaxPageHandler getAjaxPageHandler() { - return ajaxPageHandler; + protected AjaxPageHandler createAjaxPageHandler() { + return new AjaxPageHandler() { + @Override + protected String getApplicationId(AjaxPageContext context) { + String appUrl = getAppUri(context); + + String appId = appUrl; + if ("".equals(appUrl)) { + appId = "ROOT"; + } + appId = appId.replaceAll("[^a-zA-Z0-9]", ""); + // Add hashCode to the end, so that it is still (sort of) + // predictable, but indicates that it should not be used in CSS + // and + // such: + int hashCode = appId.hashCode(); + if (hashCode < 0) { + hashCode = -hashCode; + } + appId = appId + "-" + hashCode; + return appId; + } + + @Override + protected String getAppUri(AjaxPageContext context) { + /* Fetch relative url to application */ + // don't use server and port in uri. It may cause problems with + // some + // virtual server configurations which lose the server name + Application application = context.getApplication(); + URL url = application.getURL(); + String appUrl = url.getPath(); + if (appUrl.endsWith("/")) { + appUrl = appUrl.substring(0, appUrl.length() - 1); + } + return appUrl; + } + + @Override + public String getThemeName(AjaxPageContext context) { + String themeName = context.getRequest().getParameter( + AbstractApplicationServlet.URL_PARAMETER_THEME); + if (themeName == null) { + themeName = super.getThemeName(context); + } + return themeName; + } + + @Override + protected AbstractCommunicationManager getCommunicationManager() { + return CommunicationManager.this; + } + }; } } |