use of com.haulmont.cuba.web.gui.UrlHandlingMode in project cuba by cuba-platform.
the class AppUI method initHistoryBackControl.
protected void initHistoryBackControl() {
boolean allowHistoryBack = webConfig.getAllowHandleBrowserHistoryBack();
UrlHandlingMode urlHandlingMode = webConfig.getUrlHandlingMode();
if (allowHistoryBack && urlHandlingMode != UrlHandlingMode.BACK_ONLY) {
log.info("Deprecated 'WebConfig#getAllowHandleBrowserHistoryBack' config use is ignored. " + "Please use new 'WebConfig#getUrlHandlingMode' to enable this feature.");
}
if (urlHandlingMode == UrlHandlingMode.BACK_ONLY) {
CubaHistoryControl historyControl = new CubaHistoryControl();
historyControl.extend(this, this::onHistoryBackPerformed);
}
}
use of com.haulmont.cuba.web.gui.UrlHandlingMode in project cuba by cuba-platform.
the class RedirectHandler method redirect.
public void redirect() {
UrlHandlingMode urlHandlingMode = webConfig.getUrlHandlingMode();
if (UrlHandlingMode.URL_ROUTES != urlHandlingMode) {
log.debug("RedirectHandler is disabled for {} URL handling mode", urlHandlingMode);
return;
}
String nestedRoute = redirect.getNestedRoute();
Map<String, String> params = redirect.getParams();
String redirectTarget = null;
if (StringUtils.isNotEmpty(nestedRoute)) {
redirectTarget = nestedRoute;
} else if (MapUtils.isNotEmpty(params) && params.containsKey(REDIRECT_PARAM)) {
redirectTarget = params.remove(REDIRECT_PARAM);
}
if (StringUtils.isEmpty(redirectTarget)) {
return;
}
NavigationState currentState = ui.getUrlRouting().getState();
NavigationState newState = new NavigationState(currentState.getRoot(), "", redirectTarget, params);
ui.getUrlChangeHandler().getScreenNavigator().handleScreenNavigation(newState);
redirect = null;
}
use of com.haulmont.cuba.web.gui.UrlHandlingMode in project cuba by cuba-platform.
the class RedirectHandler method schedule.
public void schedule(NavigationState redirect) {
UrlHandlingMode urlHandlingMode = webConfig.getUrlHandlingMode();
if (UrlHandlingMode.URL_ROUTES != urlHandlingMode) {
log.debug("RedirectHandler is disabled for {} URL handling mode", urlHandlingMode);
return;
}
Preconditions.checkNotNullArgument(redirect);
RouteDefinition notFoundScreenRouteDef = windowConfig.getWindowInfo(NotFoundScreen.ID).getRouteDefinition();
if (Objects.equals(notFoundScreenRouteDef.getPath(), redirect.getNestedRoute())) {
return;
}
this.redirect = redirect;
String nestedRoute = redirect.getNestedRoute();
if (StringUtils.isEmpty(nestedRoute)) {
return;
}
Map<String, String> params = new LinkedHashMap<>();
params.put(REDIRECT_PARAM, nestedRoute);
if (redirect.getParams() != null) {
params.putAll(redirect.getParams());
}
RootWindow rootWindow = ui.getTopLevelWindow();
if (rootWindow != null) {
ui.getUrlRouting().replaceState(rootWindow.getFrameOwner(), params);
}
}
Aggregations