Search in sources :

Example 1 with LinkHandler

use of com.haulmont.cuba.web.sys.LinkHandler in project cuba by cuba-platform.

the class ScreenHistoryBrowse method openUrl.

protected void openUrl(Entity entity) {
    ScreenHistoryEntity screenHistoryEntity = (ScreenHistoryEntity) entity;
    Map<String, String> paramsScreen = new HashMap<>();
    String url = screenHistoryEntity.getUrl();
    url = url.substring(url.indexOf("\u003f") + 1);
    paramsScreen.put("local", "true");
    String[] params = url.split("&");
    for (String param : params) {
        String name = param.split("=")[0];
        String value = param.split("=")[1];
        paramsScreen.put(name, value);
    }
    List<String> actions = configuration.getConfig(WebConfig.class).getLinkHandlerActions();
    LinkHandler linkHandler = AppBeans.getPrototype(LinkHandler.NAME, App.getInstance(), actions.isEmpty() ? "open" : actions.get(0), paramsScreen);
    if (linkHandler.canHandleLink()) {
        linkHandler.handle();
    }
}
Also used : ScreenHistoryEntity(com.haulmont.cuba.security.entity.ScreenHistoryEntity) HashMap(java.util.HashMap) WebConfig(com.haulmont.cuba.web.WebConfig) LinkHandler(com.haulmont.cuba.web.sys.LinkHandler)

Example 2 with LinkHandler

use of com.haulmont.cuba.web.sys.LinkHandler in project cuba by cuba-platform.

the class AppUI method processExternalLink.

public void processExternalLink(VaadinRequest request) {
    WrappedSession wrappedSession = request.getWrappedSession();
    String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR);
    if (webConfig.getLinkHandlerActions().contains(action)) {
        // noinspection unchecked
        Map<String, String> params = (Map<String, String>) wrappedSession.getAttribute(LAST_REQUEST_PARAMS_ATTR);
        params = params != null ? params : Collections.emptyMap();
        try {
            LinkHandler linkHandler = AppBeans.getPrototype(LinkHandler.NAME, app, action, params);
            if (app.connection.isConnected() && linkHandler.canHandleLink()) {
                linkHandler.handle();
            } else {
                app.linkHandler = linkHandler;
            }
        } catch (Exception e) {
            error(new com.vaadin.server.ErrorEvent(e));
        }
    }
}
Also used : WrappedSession(com.vaadin.server.WrappedSession) LinkHandler(com.haulmont.cuba.web.sys.LinkHandler) LoginException(com.haulmont.cuba.security.global.LoginException)

Aggregations

LinkHandler (com.haulmont.cuba.web.sys.LinkHandler)2 ScreenHistoryEntity (com.haulmont.cuba.security.entity.ScreenHistoryEntity)1 LoginException (com.haulmont.cuba.security.global.LoginException)1 WebConfig (com.haulmont.cuba.web.WebConfig)1 WrappedSession (com.vaadin.server.WrappedSession)1 HashMap (java.util.HashMap)1