Package com.vaadin.flow.router
Class NavigationEvent
- java.lang.Object
-
- java.util.EventObject
-
- com.vaadin.flow.router.NavigationEvent
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ErrorNavigationEvent
public class NavigationEvent extends EventObject
Event object with data related to navigation.- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description NavigationEvent(Router router, Location location, UI ui, NavigationTrigger trigger)Creates a new navigation event.NavigationEvent(Router router, Location location, UI ui, NavigationTrigger trigger, elemental.json.JsonValue state, boolean forwardTo)Creates a new navigation event.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocationgetLocation()Gets the new location.RoutergetSource()Optional<elemental.json.JsonValue>getState()Gets navigation state.NavigationTriggergetTrigger()Gets the type of user action that triggered this navigation event.UIgetUI()Gets the UI in which the navigation occurs.booleanisForwardTo()Checks whether this event is created as a result ofBeforeEvent.forwardTo(com.vaadin.flow.router.NavigationHandler, com.vaadin.flow.router.NavigationState)or not.-
Methods inherited from class java.util.EventObject
toString
-
-
-
-
Constructor Detail
-
NavigationEvent
public NavigationEvent(Router router, Location location, UI ui, NavigationTrigger trigger)
Creates a new navigation event.- Parameters:
router- the router handling the navigation, notnulllocation- the new location, notnullui- the UI in which the navigation occurs, notnulltrigger- the type of user action that triggered this navigation event, notnull
-
NavigationEvent
public NavigationEvent(Router router, Location location, UI ui, NavigationTrigger trigger, elemental.json.JsonValue state, boolean forwardTo)
Creates a new navigation event.- Parameters:
router- the router handling the navigation, notnulllocation- the new location, notnullui- the UI in which the navigation occurs, notnulltrigger- the type of user action that triggered this navigation event, notnullstate- includes navigation state info including for example the scroll position and the complete href of the RouterLinkforwardTo- indicates if this event is created as a result ofBeforeEvent.forwardTo(com.vaadin.flow.router.NavigationHandler, com.vaadin.flow.router.NavigationState)or not
-
-
Method Detail
-
getSource
public Router getSource()
- Overrides:
getSourcein classEventObject
-
getLocation
public Location getLocation()
Gets the new location.- Returns:
- the new location, not
null
-
getUI
public UI getUI()
Gets the UI in which the navigation occurs.- Returns:
- the UI of the navigation
-
getTrigger
public NavigationTrigger getTrigger()
Gets the type of user action that triggered this navigation event.- Returns:
- the type of user action that triggered this navigation event, not
null
-
getState
public Optional<elemental.json.JsonValue> getState()
Gets navigation state. It contains for example the scroll position and the complete href of the RouterLink that triggers this navigation.- Returns:
- the navigation state
-
isForwardTo
public boolean isForwardTo()
Checks whether this event is created as a result ofBeforeEvent.forwardTo(com.vaadin.flow.router.NavigationHandler, com.vaadin.flow.router.NavigationState)or not.- Returns:
trueif this event is created as a result callingBeforeEvent.forwardTo(com.vaadin.flow.router.NavigationHandler, com.vaadin.flow.router.NavigationState),falseotherwise
-
-