public class Router extends Object implements Serializable
Route,
Serialized Form| Constructor and Description |
|---|
Router(RouteRegistry registry)
Constructs a new router with the given route registry and a
DefaultRouteResolver. |
| Modifier and Type | Method and Description |
|---|---|
Optional<ErrorTargetEntry> |
getErrorNavigationTarget(Exception exception)
Get a registered navigation target for given exception.
|
RouteRegistry |
getRegistry() |
void |
initializeUI(UI ui,
Location location)
Enables navigation for a new UI instance.
|
void |
initializeUI(UI ui,
VaadinRequest initRequest)
Enables navigation for a new UI instance.
|
int |
navigate(UI ui,
Location location,
NavigationTrigger trigger)
Navigates the given UI to the given location.
|
int |
navigate(UI ui,
Location location,
NavigationTrigger trigger,
elemental.json.JsonValue state)
Navigates the given UI to the given location.
|
Optional<NavigationState> |
resolveNavigationTarget(Location location)
Resolve the navigation target for given
Location using the router
routeResolver. |
Optional<NavigationState> |
resolveNavigationTarget(String pathInfo,
Map<String,String[]> parameterMap)
Resolve the navigation target for given path and parameter map using the
router routeResolver.
|
Optional<NavigationState> |
resolveRouteNotFoundNavigationTarget()
Resolve a navigation target with an empty
NotFoundException. |
public Router(RouteRegistry registry)
DefaultRouteResolver.registry - the route registry to use, not nullpublic void initializeUI(UI ui, VaadinRequest initRequest)
ui - the UI that navigation should be set up forinitRequest - the Vaadin request that bootstraps the provided UIpublic void initializeUI(UI ui, Location location)
ui - the UI that navigation should be set up forlocation - the location object of the routepublic Optional<NavigationState> resolveNavigationTarget(String pathInfo, Map<String,String[]> parameterMap)
pathInfo - the path relative to the applicationparameterMap - A mapping of parameter names to arrays of parameter valuespublic Optional<NavigationState> resolveNavigationTarget(Location location)
Location using the router
routeResolver.location - the location object of the routepublic Optional<NavigationState> resolveRouteNotFoundNavigationTarget()
NotFoundException.NavigationState for NotFoundException or
empty if there is none in the application.public int navigate(UI ui, Location location, NavigationTrigger trigger)
This method just shows the given location on the page and doesn't
update the browser location (and page history). Use the
UI.navigate(String, QueryParameters) method if you want to update
the browser location as well.
ui - the UI to update, not nulllocation - the location to navigate to, not nulltrigger - the type of user action that triggered this navigation, not
nullUI.navigate(String),
UI.navigate(String, QueryParameters)public int navigate(UI ui, Location location, NavigationTrigger trigger, elemental.json.JsonValue state)
This method pushes to the browser history if the trigger is
NavigationTrigger.ROUTER_LINK or
NavigationTrigger.UI_NAVIGATE.
ui - the UI to update, not nulllocation - the location to navigate to, not nulltrigger - the type of user action that triggered this navigation, not
nullstate - includes navigation state info including for example the
scroll position and the complete href of the RouterLinkUI.navigate(String),
UI.navigate(String, QueryParameters)public RouteRegistry getRegistry()
public Optional<ErrorTargetEntry> getErrorNavigationTarget(Exception exception)
exception - exception to search error view forCopyright © 2021. All rights reserved.