com.vaadin.flow.router.

Class BeforeEvent

    • Constructor Detail

      • BeforeEvent

        public BeforeEvent(NavigationEvent event,
                           Class<?> navigationTarget,
                           List<Class<? extends RouterLayout>> layouts)

        Construct event from a NavigationEvent.

        Parameters:

        event - NavigationEvent that is on-going

        navigationTarget - Navigation target

        layouts - Navigation layout chain

      • BeforeEvent

        public BeforeEvent(Router router,
                           NavigationTrigger trigger,
                           Location location,
                           Class<?> navigationTarget,
                           UI ui,
                           List<Class<? extends RouterLayout>> layouts)

        Constructs a new BeforeNavigation Event.

        Parameters:

        router - the router that triggered the change, not null

        trigger - the type of user action that triggered this location change, not null

        location - the new location, not null

        navigationTarget - navigation target class

        ui - the UI related to the navigation

        layouts - the layout chain for the navigation target

    • Method Detail

      • getLocation

        public Location getLocation()

        Gets the new location.

        Returns:

        the new location, not null

      • getTrigger

        public NavigationTrigger 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

      • hasForwardTarget

        public boolean hasForwardTarget()

        Check if we have a forward target.

        Returns:

        forward target exists

      • hasRerouteTarget

        public boolean hasRerouteTarget()

        Check if we have a reroute target.

        Returns:

        reroute target exists

      • getForwardTarget

        public NavigationHandler getForwardTarget()

        Gets the forward target handler to use if the user should be forwarded to some other view.

        Returns:

        navigation handler

      • getRerouteTarget

        public NavigationHandler getRerouteTarget()

        Gets the reroute target handler to use if the user should be rerouted to some other view.

        Returns:

        an navigation handler

      • forwardTo

        public void forwardTo(NavigationHandler forwardTarget,
                              NavigationState targetState)

        Forward the navigation to use the provided navigation handler instead of the currently used handler.

        Parameters:

        forwardTarget - the navigation handler to use, or null to clear a previously set forward target

        targetState - the target navigation state of the rerouting

      • forwardTo

        public void forwardTo(NavigationState targetState)

        Forward the navigation to the given navigation state.

        Parameters:

        targetState - the target navigation state, not null

      • forwardTo

        public void forwardTo(Class<? extends Component> forwardTargetComponent)

        Forward the navigation to show the given component instead of the component that is currently about to be displayed.

        Parameters:

        forwardTargetComponent - the component type to display, not null

      • forwardTo

        public void forwardTo(String location)

        Forward to navigation component registered for given location string instead of the component about to be displayed.

        Parameters:

        location - forward target location string

      • forwardTo

        public <T> void forwardTo(String location,
                                  T locationParam)

        Forward to navigation component registered for given location string with given location parameter instead of the component about to be displayed.

        Type Parameters:

        T - location parameter type

        Parameters:

        location - reroute target location string

        locationParam - location parameter

      • forwardTo

        public <T> void forwardTo(String location,
                                  List<T> locationParams)

        Forward to navigation component registered for given location string with given location parameters instead of the component about to be displayed.

        Type Parameters:

        T - location parameters type

        Parameters:

        location - reroute target location string

        locationParams - location parameters

      • rerouteTo

        public void rerouteTo(NavigationHandler rerouteTarget,
                              NavigationState targetState)

        Reroutes the navigation to use the provided navigation handler instead of the currently used handler.

        Parameters:

        rerouteTarget - the navigation handler to use, or null to clear a previously set reroute target

        targetState - the target navigation state of the rerouting

      • rerouteTo

        public void rerouteTo(NavigationState targetState)

        Reroutes the navigation to the given navigation state.

        Parameters:

        targetState - the target navigation state of the rerouting, not null

      • rerouteTo

        public void rerouteTo(Class<? extends Component> routeTargetType)

        Reroutes the navigation to show the given component instead of the component that is currently about to be displayed.

        Parameters:

        routeTargetType - the component type to display, not null

      • rerouteTo

        public void rerouteTo(String route)

        Reroute to navigation component registered for given location string instead of the component about to be displayed.

        Parameters:

        route - reroute target location string

      • rerouteTo

        public <T> void rerouteTo(String route,
                                  T routeParam)

        Reroute to navigation component registered for given location string with given route parameter instead of the component about to be displayed.

        Type Parameters:

        T - route parameter type

        Parameters:

        route - reroute target location string

        routeParam - route parameter

      • rerouteTo

        public <T> void rerouteTo(String route,
                                  List<T> routeParams)

        Reroute to navigation component registered for given location string with given route parameters instead of the component about to be displayed.

        Type Parameters:

        T - route parameters type

        Parameters:

        route - reroute target location string

        routeParams - route parameters

      • getForwardTargetType

        public Class<? extends Component> getForwardTargetType()

        Get the forward target type for forwarding.

        Returns:

        forward target type

      • getForwardTargetParameters

        public List<String> getForwardTargetParameters()

        Get the URL parameters of the forward target.

        Returns:

        URL parameters of forward target

      • getRerouteTargetType

        public Class<? extends Component> getRerouteTargetType()

        Get the route target type for rerouting.

        Returns:

        route target type

      • getRerouteTargetParameters

        public List<String> getRerouteTargetParameters()

        Get the URL parameters of the reroute target.

        Returns:

        URL parameters of reroute target

      • getNavigationTarget

        public Class<?> getNavigationTarget()

        Get the navigation target.

        Returns:

        navigation target

      • rerouteToError

        public void rerouteToError(Class<? extends Exception> exception)

        Reroute to error target for given exception without custom message.

        Exception class needs to have default no-arg constructor.

        Parameters:

        exception - exception to get error target for

        See Also:

        rerouteToError(Exception, String)

      • rerouteToError

        public void rerouteToError(Class<? extends Exception> exception,
                                   String customMessage)

        Reroute to error target for given exception with given custom message.

        Exception class needs to have default no-arg constructor.

        Parameters:

        exception - exception to get error target for

        customMessage - custom message to send to error target

        See Also:

        rerouteToError(Exception, String)

      • rerouteToError

        public void rerouteToError(Exception exception,
                                   String customMessage)

        Reroute to error target for given exception with given custom message.

        Parameters:

        exception - exception to get error target for

        customMessage - custom message to send to error target

      • hasErrorParameter

        public boolean hasErrorParameter()

        Check if we have an error parameter set for this navigation event.

        Returns:

        true if error parameter is set

      • getErrorParameter

        public ErrorParameter<?> getErrorParameter()

        Get the set error parameter.

        Returns:

        error parameter

      • getUI

        public UI getUI()

        Gets the UI this navigation takes place inside.

        Returns:

        the related UI instance