diff options
author | Artur <artur@vaadin.com> | 2017-04-27 14:05:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-27 14:05:50 +0300 |
commit | 85c004ee4ddeb08710f8dbb957a320f1d2faa266 (patch) | |
tree | 2775fbcae5ea242cc72feb2936db4bcc197b0995 /server/src/main | |
parent | 7dbc5414239ae6c84d4e48be7321798e79709db5 (diff) | |
download | vaadin-framework-85c004ee4ddeb08710f8dbb957a320f1d2faa266.tar.gz vaadin-framework-85c004ee4ddeb08710f8dbb957a320f1d2faa266.zip |
Make Bootstrap URIResolver available to bootstrap listeners (#9171)
Without access to the URIResolver it is impossible to add script
and other URLs using a listener
Diffstat (limited to 'server/src/main')
-rw-r--r-- | server/src/main/java/com/vaadin/server/BootstrapHandler.java | 8 | ||||
-rw-r--r-- | server/src/main/java/com/vaadin/server/BootstrapResponse.java | 36 |
2 files changed, 36 insertions, 8 deletions
diff --git a/server/src/main/java/com/vaadin/server/BootstrapHandler.java b/server/src/main/java/com/vaadin/server/BootstrapHandler.java index 2832ecb326..82248234ef 100644 --- a/server/src/main/java/com/vaadin/server/BootstrapHandler.java +++ b/server/src/main/java/com/vaadin/server/BootstrapHandler.java @@ -308,9 +308,12 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { return false; } + BootstrapFragmentResponse bootstrapResponse = new BootstrapFragmentResponse( + this, request, session, uiClass, new ArrayList<>(), + provider); BootstrapContext context = new BootstrapContext(response, - new BootstrapFragmentResponse(this, request, session, - uiClass, new ArrayList<>(), provider)); + bootstrapResponse); + bootstrapResponse.setUriResolver(context.getUriResolver()); setupMainDiv(context); @@ -342,6 +345,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { BootstrapPageResponse pageResponse = new BootstrapPageResponse(this, request, context.getSession(), context.getUIClass(), document, headers, fragmentResponse.getUIProvider()); + pageResponse.setUriResolver(context.getUriResolver()); List<Node> fragmentNodes = fragmentResponse.getFragmentNodes(); Element body = document.body(); for (Node node : fragmentNodes) { diff --git a/server/src/main/java/com/vaadin/server/BootstrapResponse.java b/server/src/main/java/com/vaadin/server/BootstrapResponse.java index 9b1a86e139..3f24be3dca 100644 --- a/server/src/main/java/com/vaadin/server/BootstrapResponse.java +++ b/server/src/main/java/com/vaadin/server/BootstrapResponse.java @@ -18,6 +18,7 @@ package com.vaadin.server; import java.util.EventObject; +import com.vaadin.shared.VaadinUriResolver; import com.vaadin.ui.UI; /** @@ -32,6 +33,7 @@ public abstract class BootstrapResponse extends EventObject { private final VaadinSession session; private final Class<? extends UI> uiClass; private final UIProvider uiProvider; + private VaadinUriResolver uriResolver; /** * Creates a new bootstrap event. @@ -59,7 +61,7 @@ public abstract class BootstrapResponse extends EventObject { } /** - * Gets the bootstrap handler that fired this event + * Gets the bootstrap handler that fired this event. * * @return the bootstrap handler that fired this event */ @@ -69,11 +71,12 @@ public abstract class BootstrapResponse extends EventObject { /** * Gets the request for which the generated bootstrap HTML will be the - * response. This can be used to read request headers and other additional - * information. Please note that {@link VaadinSession#getBrowser()} - * will not be available because the bootstrap page is generated before the - * bootstrap javascript has had a chance to send any information back to the - * server. + * response. + * + * This can be used to read request headers and other additional + * information. Please note that {@link VaadinSession#getBrowser()} will not + * be available because the bootstrap page is generated before the bootstrap + * javascript has had a chance to send any information back to the server. * * @return the Vaadin request that is being handled */ @@ -110,4 +113,25 @@ public abstract class BootstrapResponse extends EventObject { return uiProvider; } + /** + * Sets the URI resolver used in the bootstrap process. + * + * @param uriResolver + * the uri resolver which is used + */ + public void setUriResolver(VaadinUriResolver uriResolver) { + assert this.uriResolver == null : "URI resolver should never be changed"; + assert uriResolver != null : "URI resolver should never be null"; + this.uriResolver = uriResolver; + } + + /** + * Gets the URI resolver used in the bootstrap process. + * + * @return the URI resolver + */ + public VaadinUriResolver getUriResolver() { + return uriResolver; + } + } |