You're viewing an older version of Vaadin JavaDoc. Please see version 24.7.0 for the latest.
com.vaadin.flow.component.page.

Class 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:

    Serialized Form

    • Constructor Detail

      • 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 Detail

      • 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