Vaadin Current View or Location
You can use the following methods to retrieve the current view, location or the browser URL:
UIInternals#getActiveViewLocation()
to get currently activeLocation
UIInternals#getActiveRouterTargetsChain()
to get currently active route chain (a list of RouterLayout components with the active location component)Page#fetchCurrentURL
to asynchronously fetch the URL from the browser (documentation)VaadinServletRequest.getRequestURL()
as documented on StackOverflow but this one is buggy: flow #17602UI.getCurrentView()
is a handy utility method which consultsgetActiveRouterTargetsChain()
The location is also available in BeforeEnterObserver
’s BeforeEnterEvent#getLocation()
and AfterNavigationObserver
’s AfterNavigationEvent#getLocation()
.
Written on December 12, 2023