Class BeforeEvent

    • Constructor Detail

      • BeforeEvent

        public BeforeEvent​(NavigationEvent event,
                           Class<?> navigationTarget,
                           List<Class<? extends RouterLayout>> layouts)
        Constructs event from a NavigationEvent.
        Parameters:
        event - NavigationEvent that is on-going, not null
        navigationTarget - navigation target, not null
        layouts - Navigation layout chain, not null
      • BeforeEvent

        public BeforeEvent​(NavigationEvent event,
                           Class<?> navigationTarget,
                           RouteParameters parameters,
                           List<Class<? extends RouterLayout>> layouts)
        Constructs event from a NavigationEvent.
        Parameters:
        event - NavigationEvent that is on-going, not null
        navigationTarget - navigation target, not null
        parameters - route parameters, not null
        layouts - Navigation layout chain, not null
      • BeforeEvent

        public BeforeEvent​(Router router,
                           NavigationTrigger trigger,
                           Location location,
                           Class<?> navigationTarget,
                           UI ui,
                           List<Class<? extends RouterLayout>> layouts)
        Constructs a new BeforeEvent.
        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, not null
        ui - the UI related to the navigation, not null
        layouts - the layout chain for the navigation target, not null
      • BeforeEvent

        public BeforeEvent​(Router router,
                           NavigationTrigger trigger,
                           Location location,
                           Class<?> navigationTarget,
                           RouteParameters parameters,
                           UI ui,
                           List<Class<? extends RouterLayout>> layouts)
        Constructs a new BeforeEvent.
        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, not null
        parameters - route parameters, not null
        ui - the UI related to the navigation, not null
        layouts - the layout chain for the navigation target, not null
    • Method Detail

      • hasUnknownForward

        public boolean hasUnknownForward()
        Gets if forward route is unknown. This is true only when a forward route is not found using forwardTo(String) method.
        Returns:
        forward route is not found in the route registry.
      • hasUnknownReroute

        public boolean hasUnknownReroute()
        Gets if reroute route is unknown. This is true only when a reroute route is not found using rerouteTo(String) method.
        Returns:
        reroute is not found in the route registry.
      • getUnknownForward

        public String getUnknownForward()
        Gets the unknown forward.
        Returns:
        the unknown forward.
      • getUnknownReroute

        public String getUnknownReroute()
        Gets the unknown reroute.
        Returns:
        the unknown reroute.
      • getExternalForwardUrl

        public String getExternalForwardUrl()
        Gets the external forward url.
        Returns:
        the external forward url or null if none has been set
      • 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
      • hasExternalForwardUrl

        public boolean hasExternalForwardUrl()
        Check if we have a forward for an external URL.
        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.

        This function changes the browser URL as opposed to rerouteTo().

        Note that query parameters of the event are preserved in the forwarded URL.

        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.

        This function changes the browser URL as opposed to rerouteTo().

        Note that query parameters of the event are preserved in the forwarded URL.

        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.

        This function changes the browser URL as opposed to rerouteTo().

        Note that query parameters of the event are preserved in the forwarded URL.

        Parameters:
        forwardTargetComponent - the component type to display, not null
      • forwardTo

        public void forwardTo​(Class<? extends Component> forwardTargetComponent,
                              RouteParameters parameters)
        Forward the navigation to show the given component instead of the component that is currently about to be displayed.

        This function changes the browser URL as opposed to rerouteTo().

        Note that query parameters of the event are preserved in the forwarded URL.

        Parameters:
        forwardTargetComponent - the component type to display, not null
        parameters - parameters for the target url.
      • forwardTo

        public void forwardTo​(String location)
        Forward to navigation component registered for given location string instead of the component about to be displayed.

        This function changes the browser URL as opposed to rerouteTo().

        Note that query parameters of the event are preserved in the forwarded URL.

        Parameters:
        location - forward target location string
      • forwardToUrl

        public void forwardToUrl​(String externalForwardUrl)
        Forward to the given URL instead of the component about to be displayed.

        This function performs a page reload in the browser with the new URL.

        Parameters:
        externalForwardUrl - 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.

        This function changes the browser URL as opposed to rerouteTo().

        Note that query parameters of the event are preserved in the forwarded URL.

        Type Parameters:
        T - location parameter type
        Parameters:
        location - forward 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.

        This function changes the browser URL as opposed to rerouteTo().

        Note that query parameters of the event are preserved in the forwarded URL.

        Type Parameters:
        T - location parameters type
        Parameters:
        location - forward 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.

        This function doesn't change the browser URL as opposed to forwardTo().

        Note that rerouting preserves the query parameters of the event.

        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.

        This function doesn't change the browser URL as opposed to forwardTo().

        Note that rerouting preserves the query parameters of the event.

        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.

        This function doesn't change the browser URL as opposed to forwardTo().

        Note that rerouting preserves the query parameters of the event.

        Parameters:
        routeTargetType - the component type to display, not null
      • rerouteTo

        public void rerouteTo​(Class<? extends Component> routeTargetType,
                              RouteParameters parameters)
        Reroutes the navigation to show the given component instead of the component that is currently about to be displayed.

        This function doesn't change the browser URL as opposed to forwardTo().

        Note that rerouting preserves the query parameters of the event.

        Parameters:
        routeTargetType - the component type to display, not null
        parameters - parameters for the target url.
      • rerouteTo

        public void rerouteTo​(String route)
        Reroute to navigation component registered for given location string instead of the component about to be displayed.

        This function doesn't change the browser URL as opposed to forwardTo().

        Note that rerouting preserves the query parameters of the event.

        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.

        This function doesn't change the browser URL as opposed to forwardTo().

        Note that rerouting preserves the query parameters of the event.

        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.

        This function doesn't change the browser URL as opposed to forwardTo().

        Note that rerouting preserves the query parameters of the event.

        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
        Throws:
        NullPointerException - if no forward target is set. Check hasForwardTarget() before accessing this method.
      • getForwardTargetRouteParameters

        public RouteParameters getForwardTargetRouteParameters()
        Gets the URL parameters of the forward target.
        Returns:
        URL parameters of forward target
        Throws:
        NullPointerException - if no forward target is set. Check hasForwardTarget() before accessing this method.
      • getRerouteTargetType

        public Class<? extends Component> getRerouteTargetType()
        Get the route target type for rerouting.
        Returns:
        route target type
        Throws:
        NullPointerException - if no reroute target is set. Check hasRerouteTarget() before accessing this method.
      • getRerouteTargetRouteParameters

        public RouteParameters getRerouteTargetRouteParameters()
        Get the URL parameters of the reroute target.
        Returns:
        URL parameters of reroute target
        Throws:
        NullPointerException - if no reroute target is set. Check hasRerouteTarget() before accessing this method.
      • getNavigationTarget

        public Class<?> getNavigationTarget()
        Get the navigation target.
        Returns:
        navigation target
      • getRouteParameters

        public RouteParameters getRouteParameters()
        Gets the route parameters associated with this event.
        Returns:
        route parameters retrieved from the navigation url.
      • 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