use of com.vaadin.flow.router.HasUrlParameter in project flow by vaadin.
the class NavigationStateRenderer method notifyNavigationTarget.
@Override
protected void notifyNavigationTarget(Component componentInstance, NavigationEvent navigationEvent, BeforeEnterEvent beforeEnterEvent, LocationChangeEvent locationChangeEvent) {
if (!(componentInstance instanceof HasUrlParameter)) {
return;
}
NavigationState navigationState = getNavigationState();
Class<? extends Component> routeTargetType = navigationState.getNavigationTarget();
List<String> parameters = navigationState.getUrlParameters().orElse(null);
Object deserializedParameter = null;
try {
deserializedParameter = ParameterDeserializer.deserializeRouteParameters(routeTargetType, parameters);
} catch (Exception e) {
beforeEnterEvent.rerouteToError(NotFoundException.class, String.format("Failed to parse url parameter, exception: %s", e));
return;
}
HasUrlParameter<Object> hasUrlParameter = (HasUrlParameter<Object>) componentInstance;
hasUrlParameter.setParameter(beforeEnterEvent, deserializedParameter);
}
Aggregations