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:
  • Constructor Details

    • NavigationEvent

      public NavigationEvent(Router router, Location location, UI ui, NavigationTrigger trigger)
      Creates a new navigation event.
      Parameters:
      router - the router handling the navigation, not null
      location - the new location, not null
      ui - the UI in which the navigation occurs, not null
      trigger - the type of user action that triggered this navigation event, not null
    • 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, not null
      location - the new location, not null
      ui - the UI in which the navigation occurs, not null
      trigger - the type of user action that triggered this navigation event, not null
      state - includes navigation state info including for example the scroll position and the complete href of the RouterLink
      forwardTo - indicates if this event is created as a result of BeforeEvent.forwardTo(com.vaadin.flow.router.NavigationHandler, com.vaadin.flow.router.NavigationState) or not
    • NavigationEvent

      public NavigationEvent(Router router, Location location, UI ui, NavigationTrigger trigger, elemental.json.JsonValue state, boolean forwardTo, boolean forceInstantiation, boolean recreateLayoutChain)
      Creates a new navigation event.
      Parameters:
      router - the router handling the navigation, not null
      location - the new location, not null
      ui - the UI in which the navigation occurs, not null
      trigger - the type of user action that triggered this navigation event, not null
      state - includes navigation state info including for example the scroll position and the complete href of the RouterLink
      forwardTo - indicates if this event is created as a result of BeforeEvent.forwardTo(com.vaadin.flow.router.NavigationHandler, com.vaadin.flow.router.NavigationState) or not
      forceInstantiation - if set to true, the navigation target will always be instantiated
      recreateLayoutChain - if set to true, the complete layout chain up to the navigation target will be re-instantiated. Requires forceInstantiation to be true to have an effect.
  • Method Details

    • getSource

      public Router getSource()
      Overrides:
      getSource in class EventObject
    • 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()
      Returns:
      true if this event is created as a result calling BeforeEvent.forwardTo(com.vaadin.flow.router.NavigationHandler, com.vaadin.flow.router.NavigationState), false otherwise
    • isForceInstantiation

      public boolean isForceInstantiation()
      When set to true, the navigation target should be instantiated regardless of it being already available.
      Returns:
      true if navigation target should be instantiated in any case
    • isRecreateLayoutChain

      public boolean isRecreateLayoutChain()
      When set to true, the complete layout chain up to the navigation target should be re-instantiated regardless of it being already available.
      Returns:
      true if layout chain up to the navigation target should be instantiated in any case