Package com.vaadin.flow.router
Class LocationChangeEvent
java.lang.Object
java.util.EventObject
com.vaadin.flow.router.LocationChangeEvent
- All Implemented Interfaces:
Serializable
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 specifiedparameterName.Gets the query parameters used for navigation.Deprecated, for removal: This API element is subject to removal in a future version.Gets the chain of route targets that will be nested inside the UI, starting from the most deeply nested component.intGets 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.voidrerouteTo(NavigationHandler rerouteTarget) Deprecated, for removal: This API element is subject to removal in a future version.reroute from aBeforeEnterObserverorBeforeLeaveObserverwithBeforeEvent.rerouteTo(NavigationHandler, NavigationState)insteadvoidrerouteTo(NavigationState rerouteTargetState) Deprecated, for removal: This API element is subject to removal in a future version.reroute from aBeforeEnterObserverorBeforeLeaveObserverwithBeforeEvent.rerouteTo(NavigationState)insteadvoidsetStatusCode(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 usegetQueryParameter(String)- Returns:
- the query parameters, not
null
-
getQueryParameter
Gets first parameter that corresponds to specifiedparameterName. 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 get- Returns:
- first corresponding query parameter or
Optional.empty(), if no parameters found forparameterNamespecified
-
getSource
- Overrides:
getSourcein 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.The router reads this value right after the route target has been shown and before the after-navigation events are fired, so a value set from an
AfterNavigationEventis never returned to the client.- 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.Only effective while the navigation is still being resolved, i.e. from
HasErrorParameter.setErrorParameter(BeforeEnterEvent, ErrorParameter). The router has already read the status code by the time the after-navigation events are fired, so a value set from anAfterNavigationEventnever reaches the client. It is still returned bygetStatusCode(), and setting it that late logs a warning.- Parameters:
statusCode- the http status code
-
getRerouteTarget
Deprecated, for removal: This API element is subject to removal in a future version.the router never reads this value; useBeforeEvent.getRerouteTarget()insteadGets 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
-
BeforeEvent.getRerouteTarget()instead