summaryrefslogtreecommitdiffstats
path: root/shared
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-02-22 10:35:44 +0200
committerIlia Motornyi <elmot@vaadin.com>2017-02-22 10:35:44 +0200
commitbba4e4037bbfa7bfd5f71718806a92bb351e2fe8 (patch)
tree75c5481b87f1a477ffac07bd1b77c009586abae8 /shared
parentaf1412adad6131a9603dc6854186ec896fb90f61 (diff)
downloadvaadin-framework-bba4e4037bbfa7bfd5f71718806a92bb351e2fe8.tar.gz
vaadin-framework-bba4e4037bbfa7bfd5f71718806a92bb351e2fe8.zip
Translate "context://" to the context root of the web app
Fixes #2523
Diffstat (limited to 'shared')
-rw-r--r--shared/src/main/java/com/vaadin/shared/ApplicationConstants.java10
-rw-r--r--shared/src/main/java/com/vaadin/shared/VaadinUriResolver.java14
2 files changed, 24 insertions, 0 deletions
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
@@ -73,6 +77,12 @@ public class ApplicationConstants implements Serializable {
/**
* 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.
* <p>
* <b>Refactor warning:</b> This value is also hardcoded in
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;
}
@@ -141,6 +148,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.
*
* @return the URI of the current theme directory