Class BrowserWindowOpener

    • Constructor Detail

      • BrowserWindowOpener

        public BrowserWindowOpener​(java.lang.Class<? extends UI> uiClass)
        Creates a window opener that will open windows containing the provided UI class.

        Note: The new UI instance will not work with dependency injection (CDI and Spring). Use BrowserWindowOpener(java.lang.String) instead. VaadinServlet.getCurrent().getServletContext().getContextPath() gives the current context path.

        Parameters:
        uiClass - the UI class that should be opened when the extended component is clicked
      • BrowserWindowOpener

        public BrowserWindowOpener​(java.lang.Class<? extends UI> uiClass,
                                   java.lang.String path)
        Creates a window opener that will open windows containing the provided UI using the provided path.

        Note: The new UI instance will not work with dependency injection (CDI and Spring). Use BrowserWindowOpener(java.lang.String) instead. VaadinServlet.getCurrent().getServletContext().getContextPath() gives the current context path.

        Parameters:
        uiClass - the UI class that should be opened when the extended component is clicked
        path - the path that the UI should be bound to
      • BrowserWindowOpener

        public BrowserWindowOpener​(java.lang.String url)
        Creates a window opener that will open windows to the provided URL.
        Parameters:
        url - the URL to open in the window
      • BrowserWindowOpener

        public BrowserWindowOpener​(Resource resource)
        Creates a window opener that will open window to the provided resource.
        Parameters:
        resource - the resource to open in the window
    • Method Detail

      • extend

        public void extend​(AbstractComponent target)
        Add this extension to the target component.
        Parameters:
        target - the component to attach this extension to
      • extend

        public void extend​(EventTrigger eventTrigger)
        Add this extension to the EventTrigger.
        Parameters:
        eventTrigger - the trigger to attach this extension to
        Since:
        8.4
      • setUrl

        public void setUrl​(java.lang.String url)
        Sets the provided URL url for this instance. The url will be opened in a new browser window/tab when the extended component is clicked.
        Parameters:
        url - URL to open
        Since:
        7.4
      • setResource

        public void setResource​(Resource resource)
        Sets the provided resource for this instance. The resource will be opened in a new browser window/tab when the extended component is clicked.
        Parameters:
        resource - resource to open
        Since:
        7.4
      • getResource

        public Resource getResource()
        Returns the resource for this instance.
        Returns:
        resource to open browser window
        Since:
        7.4
      • getUrl

        public java.lang.String getUrl()
        Returns the URL for this BrowserWindowOpener instance. Returns null if this instance is not URL resource based (a non URL based resource has been set for it).
        Returns:
        URL to open in the new browser window/tab when the extended component is clicked
        Since:
        7.4
      • setWindowName

        public void setWindowName​(java.lang.String windowName)
        Sets the target window name that will be used. If a window has already been opened with the same name, the contents of that window will be replaced instead of opening a new window. If the name is null or "_blank", a new window will always be opened.
        Parameters:
        windowName - the target name for the window
      • getWindowName

        public java.lang.String getWindowName()
        Gets the target window name.
        Returns:
        the window target string
        See Also:
        setWindowName(String)
      • getFeatures

        public java.lang.String getFeatures()
        Gets the window features.
        Returns:
        See Also:
        setFeatures(String)
      • getState

        protected com.vaadin.shared.ui.BrowserWindowOpenerState getState()
        Description copied from class: AbstractClientConnector
        Returns the shared state for this connector. The shared state object is shared between the server connector and the client connector. Changes are only communicated from the server to the client and not in the other direction.

        As a side effect, marks the connector dirty so any changes done to the state will be sent to the client. Use getState(false) to avoid marking the connector as dirty.

        Overrides:
        getState in class AbstractClientConnector
        Returns:
        The shared state for this connector. Never null.
      • getState

        protected com.vaadin.shared.ui.BrowserWindowOpenerState getState​(boolean markAsDirty)
        Description copied from class: AbstractClientConnector
        Returns the shared state for this connector.
        Overrides:
        getState in class AbstractClientConnector
        Parameters:
        markAsDirty - true if the connector should automatically be marked dirty, false otherwise
        Returns:
        The shared state for this connector. Never null.
        See Also:
        AbstractClientConnector.getState()
      • setUriFragment

        public void setUriFragment​(java.lang.String uriFragment)
        Sets a URI fragment that will be added to the URI opened in the window. If the window is opened to contain a Vaadin UI, the fragment will be available using Page.getUriFragment() on the Page instance of the new UI.

        The default value is null.

        Parameters:
        uriFragment - the URI fragment string that should be included in the opened URI, or null to preserve the original fragment of the URI.
      • getUriFragment

        public java.lang.String getUriFragment()
        Gets that URI fragment configured for opened windows.
        Returns:
        the URI fragment string, or null if no fragment is configured.
        See Also:
        setUriFragment(String)
      • setParameter

        public void setParameter​(java.lang.String name,
                                 java.lang.String value)
        Sets a parameter that will be added to the query string of the opened URI. If the window is opened to contain a Vaadin UI, the parameter will be available using VaadinRequest.getParameter(String) e.g. using the request instance passed to UI.init(VaadinRequest).

        Setting a parameter with the same name as a previously set parameter will replace the previous value.

        Parameters:
        name - the name of the parameter to add, not null
        value - the value of the parameter to add, not null
        See Also:
        removeParameter(String), getParameterNames(), getParameter(String)
      • removeParameter

        public void removeParameter​(java.lang.String name)
        Removes a parameter that has been set using setParameter(String, String). Removing a parameter that has not been set has no effect.
        Parameters:
        name - the name of the parameter to remove, not null
        See Also:
        setParameter(String, String)
      • getParameter

        public java.lang.String getParameter​(java.lang.String name)
        Gets the value of a parameter set using setParameter(String, String). If there is no parameter with the given name, null is returned.
        Parameters:
        name - the name of the parameter to get, not null
        Returns:
        the value of the parameter, or null there is no parameter
        See Also:
        setParameter(String, String), getParameter(String)