com.vaadin.flow.server.communication.

Class WebComponentBootstrapHandler

All Implemented Interfaces:

RequestHandler, Serializable

public class WebComponentBootstrapHandler extends BootstrapHandler

Bootstrap handler for WebComponent requests.

For internal use only. May be renamed or removed in a future release.

Since:

2.0

Author:

Vaadin Ltd.

See Also:

  • Constructor Details

    • WebComponentBootstrapHandler

      public WebComponentBootstrapHandler()

      Creates a new bootstrap handler with default page builder.

    • WebComponentBootstrapHandler

      protected WebComponentBootstrapHandler(BootstrapHandler.PageBuilder pageBuilder)

      Creates a new bootstrap handler, allowing to use custom page builder.

      Parameters:

      pageBuilder - Page builder to use.

  • Method Details

    • addGeneratedIndexContent

      protected static void addGeneratedIndexContent(org.jsoup.nodes.Document targetDocument, elemental.json.JsonObject statsJson)
    • canHandleRequest

      protected boolean canHandleRequest(VaadinRequest request)

      Description copied from class: SynchronizedRequestHandler

      Check whether a request may be handled by this handler. This can be used as an optimization to avoid locking the session just to investigate some method property. The default implementation just returns true which means that all requests will be handled by calling SynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse) with the session locked.

      Overrides:

      canHandleRequest in class BootstrapHandler

      Parameters:

      request - the request to handle

      Returns:

      true if the request handling should continue once the session has been locked; false if there's no need to lock the session since the request would still not be handled.

    • getRequestUrl

      protected String getRequestUrl(VaadinRequest request)

      Returns the request's base url to use in constructing and initialising ui.

      Parameters:

      request - Request to the url for.

      Returns:

      Request's url.

    • createAndInitUI

      protected BootstrapHandler.BootstrapContext createAndInitUI(Class<? extends UI> uiClass, VaadinRequest request, VaadinResponse response, VaadinSession session)

      Overrides:

      createAndInitUI in class BootstrapHandler

    • createBootstrapContext

      protected BootstrapHandler.BootstrapContext createBootstrapContext(VaadinRequest request, VaadinResponse response, UI ui, Function<VaadinRequest,String> callback)

      Description copied from class: BootstrapHandler

      Creates a new instance of BootstrapHandler.BootstrapContext for given request, response and ui.

      Overrides:

      createBootstrapContext in class BootstrapHandler

      Parameters:

      request - the request object

      response - the response object

      ui - the UI object

      Returns:

      a new bootstrap context instance

    • synchronizedHandleRequest

      public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException

      Description copied from class: SynchronizedRequestHandler

      Identical to SynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse) except the VaadinSession is locked before this is called and unlocked after this has completed.

      Overrides:

      synchronizedHandleRequest in class BootstrapHandler

      Parameters:

      session - The session for the request

      request - The request to handle

      response - The response object to which a response can be written.

      Returns:

      true if a response has been written and no further request handlers should be called, otherwise false

      Throws:

      IOException - If an IO error occurred

      See Also:

    • writeBootstrapPage

      protected void writeBootstrapPage(String contentType, VaadinResponse response, org.jsoup.nodes.Element head, String serviceUrl) throws IOException

      Copies the Elements found in the given head elements into the head of the embedding website using JavaScript. Drops <base> element.

      Parameters:

      contentType - Content type of the response.

      response - VaadinResponse into which the script is written

      head - head element of Vaadin Bootstrap page. The child elements are copied into the embedding page's head using JavaScript.

      serviceUrl - base path to use for the head elements' URLs

      Throws:

      IOException - if writing fails

    • modifyPath

      protected String modifyPath(String basePath, String path)

      Create a new address for a resource which is calculated based on the request base path (servlet path) and the original path for the Vaadin resource.

      If the resource is targeted to context root with VAADIN prefix, the path part before the VAADIN is chopped of since that has been calculated to be relative to our context and would target context root instead of the serving servlet.

      Parameters:

      basePath - full servlet path, received as part of the bootstrap request. Needs to be the client-side path used, to get around proxies.

      path - original resource path

      Returns:

      new resource path, relative to basePath

    • getServiceUrl

      protected String getServiceUrl(VaadinRequest request, VaadinResponse response)

      Returns the service url needed for initialising the UI.

      Parameters:

      request - the request object

      response - the response object

      Returns:

      Service url for the given request.

    • handleWebComponentResyncRequest

      protected boolean handleWebComponentResyncRequest(BootstrapHandler.BootstrapContext context, VaadinRequest request, VaadinResponse response)

      Handles WebComponents resynchronization request

      Parameters:

      context - the bootstrap context object

      request - the request object

      response - the response object

      Returns:

      true if request has been handled, false otherwise