summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/vaadin/terminal/gwt/server/CommunicationManager.java')
-rw-r--r--src/com/vaadin/terminal/gwt/server/CommunicationManager.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
index bd31e0aa56..e352d606c1 100644
--- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
@@ -5,6 +5,7 @@
package com.vaadin.terminal.gwt.server;
import java.io.IOException;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -33,6 +34,57 @@ 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
@@ -178,4 +230,9 @@ public class CommunicationManager extends AbstractCommunicationManager {
pidToNameToStreamVariable.remove(getPaintableId((Paintable) owner));
}
}
+
+ @Override
+ protected AjaxPageHandler getAjaxPageHandler() {
+ return ajaxPageHandler;
+ }
}