Class PageUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEvent fired when the URI fragment of aPagechanges.static interfaceListener that that gets notified when the URI fragment of the page changes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a listener that gets notified every time the URI fragment of this page is changed.static voidaddUriFragmentChangedListener(com.vaadin.flow.component.page.Page p, PageUtils.UriFragmentChangedListener listener) Method to retain the Page returning expression after transformation.static intGets the last known height of the browser window in which this UI resides.static intgetBrowserWindowHeight(com.vaadin.flow.component.page.Page p) Method to retain the Page returning expression after transformation.static intGets the last known width of the browser window in which this uI resides.static intgetBrowserWindowWidth(com.vaadin.flow.component.page.Page p) Method to retain the Page returning expression after transformation.static StringGets the currently set URI fragment.static StringgetUriFragment(com.vaadin.flow.component.page.Page p) Method to retain the Page returning expression after transformation.static com.vaadin.flow.server.WebBrowserstatic com.vaadin.flow.server.WebBrowsergetWebBrowser(com.vaadin.flow.component.page.Page p) static voidInitializes the 'hashchange' event listener for the current UI.static voidMethod to retain the Page returning expression after transformation.static voidopen(com.vaadin.flow.component.page.Page p, String url, String windowName, boolean tryToOpenAsPopup) Method to retain the Page returning expression after transformation.static voidopen(com.vaadin.flow.component.page.Page p, String url, String windowName, int width, int height, BorderStyle border) Method to retain the Page returning expression after transformation.static voidOpens the given url in a window with the given name.static voidOpens the given url in a window with the given name.static voidopen(String url, String windowName, int width, int height, BorderStyle border) Opens the given URL in a window with the given size, border and name.static voidRemoves a URI fragment listener that was previously added to this page.static voidremoveUriFragmentChangedListener(com.vaadin.flow.component.page.Page p, PageUtils.UriFragmentChangedListener listener) Method to retain the Page returning expression after transformation.static voidsetUriFragment(com.vaadin.flow.component.page.Page p, String newUriFragment) Method to retain the Page returning expression after transformation.static voidsetUriFragment(com.vaadin.flow.component.page.Page p, String newUriFragment, boolean fireEvents) Method to retain the Page returning expression after transformation.static voidsetUriFragment(String newUriFragment) Sets URI fragment.static voidsetUriFragment(String newUriFragment, boolean fireEvents) Sets the fragment part in the current location URI.
-
Constructor Details
-
PageUtils
public PageUtils()
-
-
Method Details
-
getWebBrowser
public static com.vaadin.flow.server.WebBrowser getWebBrowser() -
getWebBrowser
public static com.vaadin.flow.server.WebBrowser getWebBrowser(com.vaadin.flow.component.page.Page p) -
getBrowserWindowHeight
public static int getBrowserWindowHeight()Gets the last known height of the browser window in which this UI resides.- Returns:
- the browser window height in pixels
-
getBrowserWindowHeight
public static int getBrowserWindowHeight(com.vaadin.flow.component.page.Page p) Method to retain the Page returning expression after transformation. Does nothing on Page parameter. -
getBrowserWindowWidth
public static int getBrowserWindowWidth()Gets the last known width of the browser window in which this uI resides.- Returns:
- the browser window width in pixels
-
getBrowserWindowWidth
public static int getBrowserWindowWidth(com.vaadin.flow.component.page.Page p) Method to retain the Page returning expression after transformation. Does nothing on Page parameter. -
getUriFragment
Gets the currently set URI fragment.Returns
nullif there is no fragment and an empty string if there is an empty fragment.To listen to changes in fragment, hook a
PageUtils.UriFragmentChangedEvent.- Returns:
- the current fragment in browser location URI.
- See Also:
-
getUriFragment
Method to retain the Page returning expression after transformation. Does nothing on Page parameter. -
setUriFragment
Sets URI fragment. This method fires aPageUtils.UriFragmentChangedEvent- Parameters:
newUriFragment- id of the new fragment- See Also:
-
setUriFragment
Method to retain the Page returning expression after transformation. Does nothing on Page parameter. -
addUriFragmentChangedListener
Adds a listener that gets notified every time the URI fragment of this page is changed. Please note that the initial URI fragment has already been set when a new UI is initialized, so there will not be any initial event for listeners added duringUI#init(VaadinRequest).- Parameters:
listener- the URI fragment listener to add- See Also:
-
addUriFragmentChangedListener
public static void addUriFragmentChangedListener(com.vaadin.flow.component.page.Page p, PageUtils.UriFragmentChangedListener listener) Method to retain the Page returning expression after transformation. Does nothing on Page parameter. -
initHashchangeEventListener
public static void initHashchangeEventListener()Initializes the 'hashchange' event listener for the current UI. Flow is not keeping track of fragment on server side by default.setUriFragment(String)andaddUriFragmentChangedListener(UriFragmentChangedListener)calls this by default. -
removeUriFragmentChangedListener
Removes a URI fragment listener that was previously added to this page.- Parameters:
listener- the URI fragment listener to remove- See Also:
-
removeUriFragmentChangedListener
public static void removeUriFragmentChangedListener(com.vaadin.flow.component.page.Page p, PageUtils.UriFragmentChangedListener listener) Method to retain the Page returning expression after transformation. Does nothing on Page parameter. -
setUriFragment
Sets the fragment part in the current location URI. Optionally fires aPageUtils.UriFragmentChangedEvent.The fragment is the optional last component of a URI, prefixed with a hash sign ("#").
Passing an empty string as
newFragmentsets an empty fragment (a trailing "#" in the URI.) Passingnullif there is already a non-null fragment will leave a trailing # in the URI since removing it would cause the browser to reload the page. This is not fully consistent with the semantics ofURI.- Parameters:
newUriFragment- The new fragment.fireEvents- true to fire event- See Also:
-
setUriFragment
public static void setUriFragment(com.vaadin.flow.component.page.Page p, String newUriFragment, boolean fireEvents) Method to retain the Page returning expression after transformation. Does nothing on Page parameter. -
open
Opens the given url in a window with the given name. Equivalent toopen(url, windowName, true) .The supplied
windowNameis used as the target name in a window.open call in the client. This means that special values such as "_blank", "_self", "_top", "_parent" have special meaning. An empty ornullwindow name is also a special case."", null and "_self" as
windowNameall causes the URL to be opened in the current window, replacing any old contents. For downloadable content you should avoid "_self" as "_self" causes the client to skip rendering of any other changes as it considers them irrelevant (the page will be replaced by the response from the URL). This can speed up the opening of a URL, but it might also put the client side into an inconsistent state if the window content is not completely replaced e.g., if the URL is downloaded instead of displayed in the browser."_blank" as
windowNamecauses the URL to always be opened in a new window or tab (depends on the browser and browser settings)."_top" and "_parent" as
windowNameworks as specified by the HTML standard.Any other
windowNamewill open the URL in a window with that name, either by opening a new window/tab in the browser or by replacing the contents of an existing window with that name.Please note that opening a popup window in this way may be blocked by the browser's popup-blocker because the new browser window is opened when processing a response from the server. To avoid this, you should instead use Link for opening the window because browsers are more forgiving when the window is opened directly from a client-side click event.
- Parameters:
url- the URL to open.windowName- the name of the window.
-
open
Method to retain the Page returning expression after transformation. Does nothing on Page parameter. -
open
Opens the given url in a window with the given name. Equivalent toopen(url, windowName, true) .The supplied
windowNameis used as the target name in a window.open call in the client. This means that special values such as "_blank", "_self", "_top", "_parent" have special meaning. An empty ornullwindow name is also a special case."", null and "_self" as
windowNameall causes the URL to be opened in the current window, replacing any old contents. For downloadable content you should avoid "_self" as "_self" causes the client to skip rendering of any other changes as it considers them irrelevant (the page will be replaced by the response from the URL). This can speed up the opening of a URL, but it might also put the client side into an inconsistent state if the window content is not completely replaced e.g., if the URL is downloaded instead of displayed in the browser."_blank" as
windowNamecauses the URL to always be opened in a new window or tab (depends on the browser and browser settings)."_top" and "_parent" as
windowNameworks as specified by the HTML standard.Any other
windowNamewill open the URL in a window with that name, either by opening a new window/tab in the browser or by replacing the contents of an existing window with that name.Please note that opening a popup window in this way may be blocked by the browser's popup-blocker because the new browser window is opened when processing a response from the server. To avoid this, you should instead use Link for opening the window because browsers are more forgiving when the window is opened directly from a client-side click event.
- Parameters:
url- the URL to open.windowName- the name of the window.tryToOpenAsPopup- Whether to try to force the resource to be opened in a new window
-
open
public static void open(com.vaadin.flow.component.page.Page p, String url, String windowName, boolean tryToOpenAsPopup) Method to retain the Page returning expression after transformation. Does nothing on Page parameter.
-