From bba4e4037bbfa7bfd5f71718806a92bb351e2fe8 Mon Sep 17 00:00:00 2001 From: Artur Date: Wed, 22 Feb 2017 10:35:44 +0200 Subject: Translate "context://" to the context root of the web app Fixes #2523 --- .../main/java/com/vaadin/shared/ApplicationConstants.java | 10 ++++++++++ .../src/main/java/com/vaadin/shared/VaadinUriResolver.java | 14 ++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'shared') diff --git a/shared/src/main/java/com/vaadin/shared/ApplicationConstants.java b/shared/src/main/java/com/vaadin/shared/ApplicationConstants.java index 166e75e94f..8cf30e43b5 100644 --- a/shared/src/main/java/com/vaadin/shared/ApplicationConstants.java +++ b/shared/src/main/java/com/vaadin/shared/ApplicationConstants.java @@ -35,6 +35,10 @@ public class ApplicationConstants implements Serializable { public static final String APP_PROTOCOL_PREFIX = "app://"; public static final String VAADIN_PROTOCOL_PREFIX = "vaadin://"; + /** + * An internal protocol used for referencing the application context path. + */ + public static final String CONTEXT_PROTOCOL_PREFIX = "context://"; public static final String FONTICON_PROTOCOL_PREFIX = "fonticon://"; public static final String PUBLISHED_PROTOCOL_NAME = "published"; public static final String PUBLISHED_PROTOCOL_PREFIX = PUBLISHED_PROTOCOL_NAME @@ -71,6 +75,12 @@ public class ApplicationConstants implements Serializable { */ public static final String URL_PARAMETER_REPAINT_ALL = "repaintAll"; + /** + * Configuration parameter giving the (in some cases relative) URL to the + * web application context root. + */ + public static final String CONTEXT_ROOT_URL = "contextRootUrl"; + /** * Configuration parameter giving the (in some cases relative) URL to the * VAADIN folder from where themes and widgetsets are loaded. diff --git a/shared/src/main/java/com/vaadin/shared/VaadinUriResolver.java b/shared/src/main/java/com/vaadin/shared/VaadinUriResolver.java index 169b1ce768..78bf0de598 100644 --- a/shared/src/main/java/com/vaadin/shared/VaadinUriResolver.java +++ b/shared/src/main/java/com/vaadin/shared/VaadinUriResolver.java @@ -110,6 +110,13 @@ public abstract class VaadinUriResolver implements Serializable { ApplicationConstants.VAADIN_PROTOCOL_PREFIX.length()); vaadinUri = vaadinDirUri + relativeUrl; } + if (vaadinUri + .startsWith(ApplicationConstants.CONTEXT_PROTOCOL_PREFIX)) { + final String contextRoot = getContextRootUrl(); + String relativeUrl = vaadinUri.substring( + ApplicationConstants.CONTEXT_PROTOCOL_PREFIX.length()); + vaadinUri = contextRoot + relativeUrl; + } return vaadinUri; } @@ -140,6 +147,13 @@ public abstract class VaadinUriResolver implements Serializable { */ protected abstract String getServiceUrl(); + /** + * Gets the URL pointing to the context root. + * + * @return the context root URL + */ + protected abstract String getContextRootUrl(); + /** * Gets the URI of the directory of the current theme. * -- cgit v1.2.3