Search in sources :

Example 1 with ResolveRequest

use of com.vaadin.flow.router.internal.ResolveRequest 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() + "'");
}
Also used : InternalRedirectHandler(com.vaadin.flow.router.internal.InternalRedirectHandler) ResolveRequest(com.vaadin.flow.router.internal.ResolveRequest) NavigationStateRenderer(com.vaadin.flow.router.internal.NavigationStateRenderer)

Aggregations

InternalRedirectHandler (com.vaadin.flow.router.internal.InternalRedirectHandler)1 NavigationStateRenderer (com.vaadin.flow.router.internal.NavigationStateRenderer)1 ResolveRequest (com.vaadin.flow.router.internal.ResolveRequest)1