Class History.HistoryStateChangeEvent

java.lang.Object
java.util.EventObject
com.vaadin.flow.component.page.History.HistoryStateChangeEvent
All Implemented Interfaces:
Serializable
Enclosing class:
History

public static class History.HistoryStateChangeEvent extends EventObject
Event fired when the history state has changed.

This happens when PopStateEvent is fired in the browser, or when routing has been triggered by user clicking a link marked with attribute "router-link".

Note that this event is not fired when only the hash has changed!

See Also:
  • Constructor Details

    • HistoryStateChangeEvent

      public HistoryStateChangeEvent(History history, elemental.json.JsonValue state, Location location, NavigationTrigger trigger)
      Creates a new event.
      Parameters:
      history - the history instance that fired the event, not null
      state - the history state from the browser, null if no state was provided
      location - the new browser location, not null
      trigger - the type of user action that triggered this history change, not null
  • Method Details

    • getSource

      public History getSource()
      Overrides:
      getSource in class EventObject
    • getLocation

      public Location getLocation()
      Gets the location that was opened. This is relative to the base url.
      Returns:
      the location, not null
    • getState

      public Optional<elemental.json.JsonValue> getState()
      Gets the history state value as JSON.
      Returns:
      an optional JSON state value or an empty optional if no state has been provided
    • getTrigger

      public NavigationTrigger getTrigger()
      Gets the type of user action that triggered this history change.
      Returns:
      the type of user action that triggered this history change, not null