use of com.haulmont.cuba.web.sys.navigation.UrlChangeHandler in project cuba by cuba-platform.
the class RootNavigationHandler method doHandle.
@Override
public boolean doHandle(NavigationState requestedState, AppUI ui) {
UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
if (urlChangeHandler.isEmptyState(requestedState)) {
urlChangeHandler.revertNavigationState();
return false;
}
if (!rootChanged(requestedState, ui)) {
return false;
}
String rootRoute = requestedState.getRoot();
WindowInfo windowInfo = windowConfig.findWindowInfoByRoute(rootRoute);
if (windowInfo == null) {
log.info("No registered screen found for route: '{}'", rootRoute);
urlChangeHandler.revertNavigationState();
handle404(rootRoute, ui);
return true;
}
if (urlChangeHandler.shouldRedirect(windowInfo)) {
urlChangeHandler.redirect(requestedState);
return true;
}
if (!urlChangeHandler.isPermittedToNavigate(requestedState, windowInfo)) {
return true;
}
Screen screen = ui.getScreens().create(windowInfo.getId(), OpenMode.ROOT);
boolean hasNestedRoute = StringUtils.isNotEmpty(requestedState.getNestedRoute());
if (!hasNestedRoute && MapUtils.isNotEmpty(requestedState.getParams())) {
UiControllerUtils.fireEvent(screen, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(screen, requestedState.getParams()));
((WebWindow) screen.getWindow()).setResolvedState(requestedState);
}
screen.show();
return !hasNestedRoute;
}
use of com.haulmont.cuba.web.sys.navigation.UrlChangeHandler in project cuba by cuba-platform.
the class ParamsNavigationHandler method doHandle.
@Override
public boolean doHandle(NavigationState requestedState, AppUI ui) {
UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
if (urlChangeHandler.isEmptyState(requestedState)) {
return false;
}
Screen screen = urlChangeHandler.getActiveScreen();
if (screen == null) {
log.debug("Unable to find a screen for state: '{}", requestedState);
return false;
}
Map<String, String> params = requestedState.getParams() != null ? requestedState.getParams() : Collections.emptyMap();
WebWindow window = (WebWindow) screen.getWindow();
NavigationState resolvedState = window.getResolvedState();
if (resolvedState == null || params.equals(resolvedState.getParams())) {
return false;
}
NavigationState newState = new NavigationState(resolvedState.getRoot(), resolvedState.getStateMark(), resolvedState.getNestedRoute(), params);
window.setResolvedState(newState);
UiControllerUtils.fireEvent(screen, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(screen, params));
return true;
}
use of com.haulmont.cuba.web.sys.navigation.UrlChangeHandler in project cuba by cuba-platform.
the class NoopNavigationHandler method doHandle.
@Override
public boolean doHandle(NavigationState requestedState, AppUI ui) {
UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
if (urlChangeHandler.isEmptyState(requestedState)) {
log.debug("Unable to navigate to empty route: '{}'", requestedState);
return false;
}
log.debug("Unable handle a route: '{}'", requestedState.asRoute());
urlChangeHandler.revertNavigationState();
return false;
}
Aggregations