com.vaadin.flow.router.
Class BeforeEvent
All Implemented Interfaces:
Direct Known Subclasses:
Abstract before event class that has the common functionalities for
BeforeLeaveEvent
and BeforeEnterEvent
.
Since:
1.0
See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorsConstructorDescriptionBeforeEvent
(NavigationEvent event, Class<?> navigationTarget, RouteParameters parameters, List<Class<? extends RouterLayout>> layouts) Constructs event from a NavigationEvent.
BeforeEvent
(NavigationEvent event, Class<?> navigationTarget, List<Class<? extends RouterLayout>> layouts) Constructs event from a NavigationEvent.
BeforeEvent
(Router router, NavigationTrigger trigger, Location location, Class<?> navigationTarget, UI ui, List<Class<? extends RouterLayout>> layouts) Constructs a new BeforeEvent.
BeforeEvent
(Router router, NavigationTrigger trigger, Location location, Class<?> navigationTarget, RouteParameters parameters, UI ui, List<Class<? extends RouterLayout>> layouts) Constructs a new BeforeEvent.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.
<C extends Component>
voidforwardTo
(Class<? extends C> forwardTargetComponent, QueryParameters queryParameters) Forward the navigation to show the given component with given query parameters instead of the component that is currently about to be displayed.
<C extends Component>
voidforwardTo
(Class<? extends C> forwardTargetComponent, RouteParameters routeParameters, QueryParameters queryParameters) Forward the navigation to show the given component with given route parameters and query parameters instead of the component that is currently about to be displayed.
<T,
C extends Component & HasUrlParameter<T>>
voidForward the navigation to show the given component with given route parameters instead of the component that is currently about to be displayed.
<T,
C extends Component & HasUrlParameter<T>>
voidForward the navigation to show the given component with given route parameter instead of the component that is currently about to be displayed.
<T,
C extends Component & HasUrlParameter<T>>
voidforwardTo
(Class<? extends C> forwardTargetComponent, T routeParameter, QueryParameters queryParameters) Forward the navigation to show the given component with given route parameter and query parameters instead of the component that is currently about to be displayed.
void
Forward the navigation to show the given component instead of the component that is currently about to be displayed.
void
Forward the navigation to show the given component instead of the component that is currently about to be displayed.
void
forwardTo
(Class<? extends Component> forwardTargetComponent, RouteParameters parameters) Forward the navigation to show the given component with given route parameters instead of the component that is currently about to be displayed.
void
Forward to navigation component registered for given location string instead of the component about to be displayed.
void
forwardTo
(String locationString, QueryParameters queryParameters) Forward to navigation component registered for given location string with given query parameters instead of the component about to be displayed.
<T> void
Forward to navigation component registered for given location string with given location parameters instead of the component about to be displayed.
<T> void
Forward to navigation component registered for given location string with given location parameter instead of the component about to be displayed.
void
forwardToUrl
(String externalForwardUrl) Forward to the given URL instead of the component about to be displayed.
Get the set error parameter.
Gets the external forward url.
Gets the forward target handler to use if the user should be forwarded to some other view.
Gets the URL parameters of the forward target.
Get the forward target type for forwarding.
Gets the reroute url.
List<Class<? extends RouterLayout>>
Get the layout chain for the
navigation target
.Gets the new location.
Class<?>
Get the navigation target.
Gets the query parameters for forwarded and rerouted URL.
Gets the reroute target handler to use if the user should be rerouted to some other view.
Get the URL parameters of the reroute target.
Get the route target type for rerouting.
Gets the reroute url.
Gets the route parameters associated with this event.
Gets the type of user action that triggered this location change.
getUI()
Gets the UI this navigation takes place inside.
Gets the unknown forward.
Gets the unknown reroute.
boolean
Check if we have an error parameter set for this navigation event.
boolean
Check if we have a forward for an external URL.
boolean
Check if we have a forward target.
boolean
Check if we have query parameters for forwarded and rerouted URL.
boolean
Check if we have a reroute target.
boolean
Gets if forward route is unknown.
boolean
Gets if reroute route is unknown.
boolean
Determines is client side callback should be requested when executing pending forward operation.
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.
<C extends Component>
voidrerouteTo
(Class<? extends C> routeTargetType, QueryParameters queryParameters) Reroutes the navigation to show the given component with given query parameters instead of the component that is currently about to be displayed.
<C extends Component>
voidrerouteTo
(Class<? extends C> routeTargetType, RouteParameters routeParameters, QueryParameters queryParameters) Reroutes the navigation to show the given component with given route parameters and query parameters instead of the component that is currently about to be displayed.
<T,
C extends Component & HasUrlParameter<T>>
voidReroutes the navigation to show the given component with given route parameters instead of the component that is currently about to be displayed.
<T,
C extends Component & HasUrlParameter<T>>
voidReroutes the navigation to show the given component with given route parameter instead of the component that is currently about to be displayed.
<T,
C extends Component & HasUrlParameter<T>>
voidrerouteTo
(Class<? extends C> routeTargetType, T routeParameter, QueryParameters queryParameters) Reroutes the navigation to show the given component with given route parameter and query parameters instead of the component that is currently about to be displayed.
void
Reroutes the navigation to show the given component instead of the component that is currently about to be displayed.
void
rerouteTo
(Class<? extends Component> routeTargetType, RouteParameters parameters) Reroutes the navigation to show the given component with given route parameters instead of the component that is currently about to be displayed.
void
Reroute to navigation component registered for given location string instead of the component about to be displayed.
void
rerouteTo
(String route, QueryParameters queryParameters) Reroute to navigation component registered for given location string with given query parameters instead of the component about to be displayed.
<T> void
Reroute to navigation component registered for given location string with given route parameters instead of the component about to be displayed.
<T> void
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 Details
-
Method Details
-
hasUnknownForward
public boolean hasUnknownForward()Gets if forward route is unknown. This is true only when a forward route is not found using
forwardTo(String)
andforwardTo(String, QueryParameters)
methods.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)
andrerouteTo(String, QueryParameters)
method.Returns:
reroute is not found in the route registry.
-
getUnknownForward
Gets the unknown forward.
Returns:
the unknown forward.
-
getUnknownReroute
Gets the unknown reroute.
Returns:
the unknown reroute.
-
getExternalForwardUrl
Gets the external forward url.
Returns:
the external forward url or
null
if none has been set -
getLocation
Gets the new location.
Returns:
the new location, not
null
-
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
Overrides:
getSource
in classEventObject
-
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
Gets the forward target handler to use if the user should be forwarded to some other view.
Returns:
navigation handler
-
getRerouteTarget
Gets the reroute target handler to use if the user should be rerouted to some other view.
Returns:
an navigation handler
-
forwardTo
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, notnull
-
forwardTo
public void forwardTo(Class<? extends Component> forwardTargetComponent, boolean useForwardCallback) 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, notnull
useForwardCallback
- true to request navigation callback from client -
forwardTo
public <T,C extends Component & HasUrlParameter<T>> void forwardTo(Class<? extends C> forwardTargetComponent, T routeParameter) Forward the navigation to show the given component with given route parameter 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.
Type Parameters:
T
- route parameter typeC
- navigation target typeParameters:
forwardTargetComponent
- the component type to display, notnull
routeParameter
- route parameter for the target -
forwardTo
public <T,C extends Component & HasUrlParameter<T>> void forwardTo(Class<? extends C> forwardTargetComponent, List<T> routeParameters) Forward the navigation to show the given component with given route parameters 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.
Type Parameters:
T
- route parameters typeC
- navigation target typeParameters:
forwardTargetComponent
- the component type to display, notnull
routeParameters
- route parameters for the target -
forwardTo
public void forwardTo(Class<? extends Component> forwardTargetComponent, RouteParameters parameters) Forward the navigation to show the given component with given route parameters 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, notnull
parameters
- route parameters for the target -
forwardTo
public <T,C extends Component & HasUrlParameter<T>> void forwardTo(Class<? extends C> forwardTargetComponent, T routeParameter, QueryParameters queryParameters) Forward the navigation to show the given component with given route parameter and query parameters instead of the component that is currently about to be displayed.
This function changes the browser URL as opposed to
rerouteTo()
.Type Parameters:
T
- route parameter typeC
- navigation target typeParameters:
forwardTargetComponent
- the component type to display, notnull
routeParameter
- route parameter for the targetqueryParameters
- query parameters for the target -
forwardTo
public <C extends Component> void forwardTo(Class<? extends C> forwardTargetComponent, RouteParameters routeParameters, QueryParameters queryParameters) Forward the navigation to show the given component with given route parameters and query parameters instead of the component that is currently about to be displayed.
This function changes the browser URL as opposed to
rerouteTo()
.Type Parameters:
C
- navigation target typeParameters:
forwardTargetComponent
- the component type to display, notnull
routeParameters
- route parameters for the targetqueryParameters
- query parameters for the target -
forwardTo
public <C extends Component> void forwardTo(Class<? extends C> forwardTargetComponent, QueryParameters queryParameters) Forward the navigation to show the given component with given query parameters instead of the component that is currently about to be displayed.
This function changes the browser URL as opposed to
rerouteTo()
.Type Parameters:
C
- navigation target typeParameters:
forwardTargetComponent
- the component type to display, notnull
queryParameters
- query parameters for the target -
forwardTo
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
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
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 typeParameters:
location
- forward target location stringlocationParam
- location parameter -
forwardTo
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 typeParameters:
location
- forward target location stringlocationParams
- location parameters -
forwardTo
Forward to navigation component registered for given location string with given query parameters instead of the component about to be displayed.
This function changes the browser URL as opposed to
rerouteTo()
.Parameters:
locationString
- forward target location stringqueryParameters
- query parameters for the target -
rerouteTo
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, notnull
-
rerouteTo
public <T,C extends Component & HasUrlParameter<T>> void rerouteTo(Class<? extends C> routeTargetType, T routeParameter) Reroutes the navigation to show the given component with given route parameter 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.
Type Parameters:
T
- route parameter typeC
- navigation target typeParameters:
routeTargetType
- the component type to display, notnull
routeParameter
- route parameter for the target -
rerouteTo
public <T,C extends Component & HasUrlParameter<T>> void rerouteTo(Class<? extends C> routeTargetType, List<T> routeParameters) Reroutes the navigation to show the given component with given route parameters 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.
Type Parameters:
T
- route parameter typeC
- navigation target typeParameters:
routeTargetType
- the component type to display, notnull
routeParameters
- route parameters for the target -
rerouteTo
Reroutes the navigation to show the given component with given route parameters 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, notnull
parameters
- parameters for the target url. -
rerouteTo
public <T,C extends Component & HasUrlParameter<T>> void rerouteTo(Class<? extends C> routeTargetType, T routeParameter, QueryParameters queryParameters) Reroutes the navigation to show the given component with given route parameter and query parameters instead of the component that is currently about to be displayed.
This function doesn't change the browser URL as opposed to
forwardTo()
.Type Parameters:
T
- route parameter typeC
- navigation target typeParameters:
routeTargetType
- the component type to display, notnull
routeParameter
- route parameter for the targetqueryParameters
- query parameters for the target -
rerouteTo
public <C extends Component> void rerouteTo(Class<? extends C> routeTargetType, RouteParameters routeParameters, QueryParameters queryParameters) Reroutes the navigation to show the given component with given route parameters and query parameters instead of the component that is currently about to be displayed.
This function doesn't change the browser URL as opposed to
forwardTo()
.Type Parameters:
C
- navigation target typeParameters:
routeTargetType
- the component type to display, notnull
routeParameters
- route parameters for the targetqueryParameters
- query parameters for the target -
rerouteTo
public <C extends Component> void rerouteTo(Class<? extends C> routeTargetType, QueryParameters queryParameters) Reroutes the navigation to show the given component with given query parameters instead of the component that is currently about to be displayed.
This function doesn't change the browser URL as opposed to
forwardTo()
.Type Parameters:
C
- navigation target typeParameters:
routeTargetType
- the component type to display, notnull
queryParameters
- query parameters for the target -
rerouteTo
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
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 typeParameters:
route
- reroute target location stringrouteParam
- route parameter -
rerouteTo
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 typeParameters:
route
- reroute target location stringrouteParams
- route parameters -
rerouteTo
Reroute to navigation component registered for given location string with given query parameters instead of the component about to be displayed.
This function doesn't change the browser URL as opposed to
forwardTo()
.Parameters:
route
- reroute target location stringqueryParameters
- query parameters for the target -
getForwardTargetType
Get the forward target type for forwarding.
Returns:
forward target type
Throws:
NullPointerException
- if no forward target is set. CheckhasForwardTarget()
before accessing this method. -
getForwardTargetRouteParameters
Gets the URL parameters of the forward target.
Returns:
URL parameters of forward target
Throws:
NullPointerException
- if no forward target is set. CheckhasForwardTarget()
before accessing this method. -
getForwardUrl
Gets the reroute url.
Returns:
the reroute url.
Throws:
NullPointerException
- if no forward target is set. CheckhasForwardTarget()
before accessing this method. -
getRerouteTargetType
Get the route target type for rerouting.
Returns:
route target type
Throws:
NullPointerException
- if no reroute target is set. CheckhasRerouteTarget()
before accessing this method. -
getRerouteTargetRouteParameters
Get the URL parameters of the reroute target.
Returns:
URL parameters of reroute target
Throws:
NullPointerException
- if no reroute target is set. CheckhasRerouteTarget()
before accessing this method. -
getRerouteUrl
Gets the reroute url.
Returns:
the reroute url.
Throws:
NullPointerException
- if no reroute target is set. CheckhasRerouteTarget()
before accessing this method. -
getRouteParameters
Gets the route parameters associated with this event.
Returns:
route parameters retrieved from the navigation url.
-
hasRedirectQueryParameters
public boolean hasRedirectQueryParameters()Check if we have query parameters for forwarded and rerouted URL.
Returns:
query parameters exists
-
getRedirectQueryParameters
Gets the query parameters for forwarded and rerouted URL.
null
means that query parameters of the event are preserved in the forwarded and rerouted URL.Returns:
query parameters for forwarding and rerouting
-
getLayouts
Get the layout chain for the
navigation target
.Returns:
layout chain
-
rerouteToError
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
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
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
Get the set error parameter.
Returns:
error parameter
-
isUseForwardCallback
public boolean isUseForwardCallback()Determines is client side callback should be requested when executing pending forward operation.
Returns:
true if callback should be used, false otherwise
-
getUI
Gets the UI this navigation takes place inside.
Returns:
the related UI instance
-