Class BootstrapHandler

    • Constructor Detail

      • BootstrapHandler

        protected BootstrapHandler​(BootstrapHandler.PageBuilder pageBuilder)
        Creates an instance of the handler using provided page builder.
        Parameters:
        pageBuilder - Page builder to use.
    • Method Detail

      • getPageBuilder

        protected BootstrapHandler.PageBuilder getPageBuilder()
        Returns the current page builder object.
        Returns:
        Page builder in charge of constructing the resulting page.
      • isFrameworkInternalRequest

        public static boolean isFrameworkInternalRequest​(VaadinRequest request)
        Checks whether the request is an internal request.

        Warning: This assumes that the VaadinRequest is targeted for a VaadinServlet and does no further checks to validate this. You want to use HandlerHelper.isFrameworkInternalRequest(String, HttpServletRequest) instead.

        This is public only so that IndexHtmlRequestHandler can access it. If you are not IndexHtmlRequestHandler, go away.

        Parameters:
        request - the request
        Returns:
        true if the request is Vaadin internal, false otherwise
      • isVaadinStaticFileRequest

        public static boolean isVaadinStaticFileRequest​(VaadinRequest request)
        Checks whether the request is a request for /VAADIN/*.

        Warning: This assumes that the VaadinRequest is targeted for a VaadinServlet and does no further checks to validate this.

        This is public only so that IndexHtmlRequestHandler can access it. If you are not IndexHtmlRequestHandler, go away.

        Parameters:
        request - the request
        Returns:
        true if the request is for /VAADIN/*, false otherwise
      • isRequestForHtml

        protected boolean isRequestForHtml​(VaadinRequest request)
        Checks if the request is potentially a request for an HTML page.
        Parameters:
        request - the request to check
        Returns:
        true if the request is potentially for HTML, false if it is certain that it is a request for a script, image or something else
      • writeErrorCodeIfRequestLocationIsInvalid

        protected boolean writeErrorCodeIfRequestLocationIsInvalid​(VaadinRequest request,
                                                                   VaadinResponse response)
                                                            throws IOException
        Checks whether the request is for a valid location, and if not, writes the error code for the response.
        Parameters:
        request - the request to check
        response - the response to write
        Returns:
        true if location was invalid and error code was written, false if not (location was valid)
        Throws:
        IOException - in case writing to response fails
      • resolvePageTitle

        protected static Optional<String> resolvePageTitle​(BootstrapHandler.BootstrapContext context)
        Resolves the initial page title for the given bootstrap context and cancels any pending JS execution for it.
        Parameters:
        context - the bootstrap context
        Returns:
        the optional initial page title
      • getUIClass

        protected static Class<? extends UI> getUIClass​(VaadinRequest request)
        Returns the UI class mapped for servlet that handles the given request.

        This method is protected for testing purposes.

        Parameters:
        request - the request for the UI
        Returns:
        the UI class for the request
      • readResource

        protected static String readResource​(String fileName)
      • getInitialUidl

        protected static elemental.json.JsonObject getInitialUidl​(UI ui)
        Generates the initial UIDL message which is included in the initial bootstrap page.
        Parameters:
        ui - the UI for which the UIDL should be generated
        Returns:
        a JSON object with the initial UIDL message
      • showWebpackErrors

        protected static void showWebpackErrors​(VaadinService service,
                                                org.jsoup.nodes.Document document)
      • setupErrorDialogs

        protected static void setupErrorDialogs​(org.jsoup.nodes.Element style)
      • setupPwa

        protected static void setupPwa​(org.jsoup.nodes.Document document,
                                       VaadinService service)