com.vaadin.flow.router.
Class LocationChangeEvent
All Implemented Interfaces:
Event created when the location changes by any of the reasons defined at
NavigationTrigger
.
Since:
1.0
See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorsConstructorDescriptionLocationChangeEvent
(Router router, UI ui, NavigationTrigger trigger, Location location, List<HasElement> routeTargetChain) Creates a new location change event.
-
Method Summary
Modifier and TypeMethodDescriptionGets the new location.
getQueryParameter
(String parameterName) Gets first parameter that corresponds to specified
parameterName
.Gets the query parameters used for navigation.
Gets the reroute target to use if the user should be rerouted to some other view.
Gets the chain of route targets that will be nested inside the UI, starting from the most deeply nested component.
int
Gets the HTTP status code that will be returned for the client if this location change is an initial rendering request.
Gets the type of user action that triggered this location change.
getUI()
Gets the UI in which the view is shown.
void
rerouteTo
(NavigationHandler rerouteTarget) Reroutes the navigation to use the provided navigation handler instead of the currently used handler.
void
rerouteTo
(NavigationState rerouteTargetState) Reroutes the navigation to show the given component instead of the component that is currently about to be displayed.
void
setStatusCode
(int statusCode) Sets the HTTP status code that will be returned for the client if this location change is an initial rendering request.
Methods inherited from class java.util.EventObject
toString
-
Constructor Details
-
Method Details
-
getLocation
Gets the new location.
Returns:
the new location, not
null
-
getRouteTargetChain
Gets the chain of route targets that will be nested inside the UI, starting from the most deeply nested component.
Returns:
the view chain, not
null
-
getUI
Gets the UI in which the view is shown.
Returns:
the UI, not
null
-
getTrigger
Gets the type of user action that triggered this location change.
Returns:
the type of user action that triggered this location change, not
null
-
getQueryParameters
Gets the query parameters used for navigation. If only the first value of parameter list is important, please use
getQueryParameter(String)
Returns:
the query parameters, not
null
-
getQueryParameter
Gets first parameter that corresponds to specified
parameterName
. If there are multiple parameters corresponding to the sameparameterName
, the first one will be returned. To access all parameters, usegetQueryParameters()
method.Parameters:
parameterName
- the name of a parameter to getReturns:
first corresponding query parameter or
Optional.empty()
, if no parameters found forparameterName
specified -
getSource
Overrides:
getSource
in classEventObject
-
getStatusCode
public int getStatusCode()Gets the HTTP status code that will be returned for the client if this location change is an initial rendering request.
Returns:
the http status code
-
setStatusCode
public void setStatusCode(int statusCode) Sets the HTTP status code that will be returned for the client if this location change is an initial rendering request.
Parameters:
statusCode
- the http status code -
getRerouteTarget
Gets the reroute target to use if the user should be rerouted to some other view.
Returns:
and optional navigation handler, or an empty optional if no reroute target has been set
-