com.vaadin.flow.router.
Class BeforeEvent
- java.lang.Object
-
- java.util.EventObject
-
- com.vaadin.flow.router.BeforeEvent
-
All Implemented Interfaces:
Direct Known Subclasses:
public abstract class BeforeEvent extends EventObject
Abstract before event class that has the common functionalities for
BeforeLeaveEvent
andBeforeEnterEvent
.Since:
1.0
See Also:
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor and Description BeforeEvent(NavigationEvent event, Class<?> navigationTarget)
Deprecated.
UseBeforeEvent(NavigationEvent, Class, List)
instead.BeforeEvent(NavigationEvent event, Class<?> navigationTarget, List<Class<? extends RouterLayout>> layouts)
Construct event from a NavigationEvent.
BeforeEvent(Router router, NavigationTrigger trigger, Location location, Class<?> navigationTarget, UI ui)
Deprecated.
BeforeEvent(Router router, NavigationTrigger trigger, Location location, Class<?> navigationTarget, UI ui, List<Class<? extends RouterLayout>> layouts)
Constructs a new BeforeNavigation Event.
-
Method Summary
All Methods Modifier and Type Method and Description 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.
void
forwardTo(NavigationHandler forwardTarget, NavigationState targetState)
Forward the navigation to use the provided navigation handler instead of the currently used handler.
void
forwardTo(NavigationState targetState)
Forward the navigation to the given navigation state.
void
forwardTo(String location)
Forward to navigation component registered for given location string instead of the component about to be displayed.
<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.
<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.
ErrorParameter<?>
getErrorParameter()
Get the set error parameter.
NavigationHandler
getForwardTarget()
Gets the forward target handler to use if the user should be forwarded to some other view.
List<String>
getForwardTargetParameters()
Get the URL parameters of the forward target.
Class<? extends Component>
getForwardTargetType()
Get the forward target type for forwarding.
List<Class<? extends RouterLayout>>
getLayouts()
Get the layout chain for the
navigation target
.Location
getLocation()
Gets the new location.
Class<?>
getNavigationTarget()
Get the navigation target.
NavigationHandler
getRerouteTarget()
Gets the reroute target handler to use if the user should be rerouted to some other view.
List<String>
getRerouteTargetParameters()
Get the URL parameters of the reroute target.
Class<? extends Component>
getRerouteTargetType()
Get the route target type for rerouting.
Class<? extends Component>
getRouteTargetType()
Deprecated.
usegetRerouteTargetType()
instead.Router
getSource()
NavigationTrigger
getTrigger()
Gets the type of user action that triggered this location change.
UI
getUI()
Gets the UI this navigation takes place inside.
boolean
hasErrorParameter()
Check if we have an error parameter set for this navigation event.
boolean
hasForwardTarget()
Check if we have a forward target.
boolean
hasRerouteTarget()
Check if we have a reroute target.
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.
void
rerouteTo(NavigationHandler rerouteTarget, NavigationState targetState)
Reroutes the navigation to use the provided navigation handler instead of the currently used handler.
void
rerouteTo(NavigationState targetState)
Reroutes the navigation to the given navigation state.
void
rerouteTo(String route)
Reroute to navigation component registered for given location string instead of the component about to be displayed.
<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.
<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.
void
rerouteToError(Class<? extends Exception> exception)
Reroute to error target for given exception without custom message.
void
rerouteToError(Class<? extends Exception> exception, String customMessage)
Reroute to error target for given exception with given custom message.
void
rerouteToError(Exception exception, String customMessage)
Reroute to error target for given exception with given custom message.
-
Methods inherited from class java.util.EventObject
toString
-
-
-
-
Constructor Detail
-
BeforeEvent
@Deprecated public BeforeEvent(NavigationEvent event, Class<?> navigationTarget)
Deprecated. Use
BeforeEvent(NavigationEvent, Class, List)
instead.Construct event from a NavigationEvent.
Parameters:
event
- NavigationEvent that is on-goingnavigationTarget
- Navigation target
-
BeforeEvent
public BeforeEvent(NavigationEvent event, Class<?> navigationTarget, List<Class<? extends RouterLayout>> layouts)
Construct event from a NavigationEvent.
Parameters:
event
- NavigationEvent that is on-goingnavigationTarget
- Navigation targetlayouts
- Navigation layout chain
-
BeforeEvent
@Deprecated public BeforeEvent(Router router, NavigationTrigger trigger, Location location, Class<?> navigationTarget, UI ui)
Deprecated. Use
BeforeEvent(Router, NavigationTrigger, Location, Class, UI, List)
instead.Constructs a new BeforeNavigation Event.
Parameters:
router
- the router that triggered the change, notnull
trigger
- the type of user action that triggered this location change, notnull
location
- the new location, notnull
navigationTarget
- navigation target classui
- the UI related to the navigation
-
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, notnull
trigger
- the type of user action that triggered this location change, notnull
location
- the new location, notnull
navigationTarget
- navigation target classui
- the UI related to the navigationlayouts
- 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
-
getSource
public Router getSource()
Overrides:
getSource
in classEventObject
-
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, ornull
to clear a previously set forward targettargetState
- 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, notnull
-
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, notnull
-
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 typeParameters:
location
- reroute target location stringlocationParam
- 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 typeParameters:
location
- reroute target location stringlocationParams
- 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, ornull
to clear a previously set reroute targettargetState
- 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, notnull
-
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, notnull
-
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 typeParameters:
route
- reroute target location stringrouteParam
- 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 typeParameters:
route
- reroute target location stringrouteParams
- 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
-
getRouteTargetType
@Deprecated public Class<? extends Component> getRouteTargetType()
Deprecated. use
getRerouteTargetType()
instead.Get the route target type for rerouting.
Returns:
route target type
-
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
-
getLayouts
public List<Class<? extends RouterLayout>> getLayouts()
Get the layout chain for the
navigation target
.Returns:
layout chain
-
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 forSee Also:
-
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 forcustomMessage
- custom message to send to error targetSee Also:
-
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 forcustomMessage
- 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
-
-