use of com.vaadin.flow.router.internal.NavigationStateRenderer in project flow by vaadin.
the class BeforeEvent method rerouteTo.
/**
* Reroutes the navigation to the given navigation state.
*
* @param targetState
* the target navigation state of the rerouting, not {@code null}
*/
public void rerouteTo(NavigationState targetState) {
Objects.requireNonNull(targetState, "targetState cannot be null");
rerouteTo(new NavigationStateRenderer(targetState), targetState);
}
use of com.vaadin.flow.router.internal.NavigationStateRenderer in project flow by vaadin.
the class Router method handleNavigation.
private int handleNavigation(UI ui, Location location, NavigationTrigger trigger) {
NavigationState newState = getRouteResolver().resolve(new ResolveRequest(this, location));
if (newState != null) {
NavigationEvent navigationEvent = new NavigationEvent(this, location, ui, trigger);
NavigationHandler handler = new NavigationStateRenderer(newState);
return handler.handle(navigationEvent);
} else if (!location.getPath().isEmpty()) {
Location slashToggledLocation = location.toggleTrailingSlash();
NavigationState slashToggledState = getRouteResolver().resolve(new ResolveRequest(this, slashToggledLocation));
if (slashToggledState != null) {
NavigationEvent navigationEvent = new NavigationEvent(this, slashToggledLocation, ui, trigger);
NavigationHandler handler = new InternalRedirectHandler(slashToggledLocation);
return handler.handle(navigationEvent);
}
}
throw new NotFoundException("Couldn't find route for '" + location.getPath() + "'");
}
Aggregations