Search in sources :

Example 1 with UrlHandlingMode

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);
    }
}
Also used : UrlHandlingMode(com.haulmont.cuba.web.gui.UrlHandlingMode)

Example 2 with UrlHandlingMode

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;
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) UrlHandlingMode(com.haulmont.cuba.web.gui.UrlHandlingMode)

Example 3 with UrlHandlingMode

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);
    }
}
Also used : RouteDefinition(com.haulmont.cuba.gui.sys.RouteDefinition) UrlHandlingMode(com.haulmont.cuba.web.gui.UrlHandlingMode) RootWindow(com.haulmont.cuba.gui.components.RootWindow) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

UrlHandlingMode (com.haulmont.cuba.web.gui.UrlHandlingMode)3 RootWindow (com.haulmont.cuba.gui.components.RootWindow)1 NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)1 RouteDefinition (com.haulmont.cuba.gui.sys.RouteDefinition)1 LinkedHashMap (java.util.LinkedHashMap)1