Search in sources :

Example 1 with FrameContext

use of com.haulmont.cuba.gui.FrameContext in project cuba by cuba-platform.

the class AbstractCollectionDatasource method getTemplateParams.

protected Map<String, Object> getTemplateParams(Map<String, Object> customParams) {
    Map<String, Object> templateParams = new HashMap<>();
    String compPerfix = ParameterInfo.Type.COMPONENT.getPrefix() + "$";
    for (ParameterInfo info : queryParameters) {
        if (info.getType() == ParameterInfo.Type.COMPONENT) {
            Object value = dsContext.getFrameContext() == null ? null : dsContext.getFrameContext().getValue(info.getPath());
            templateParams.put(compPerfix + info.getPath(), value);
        }
    }
    String customPerfix = ParameterInfo.Type.CUSTOM.getPrefix() + "$";
    for (Map.Entry<String, Object> entry : customParams.entrySet()) {
        templateParams.put(customPerfix + entry.getKey(), entry.getValue());
    }
    if (dsContext != null) {
        FrameContext windowContext = dsContext.getFrameContext();
        if (windowContext != null) {
            String paramPerfix = ParameterInfo.Type.PARAM.getPrefix() + "$";
            for (Map.Entry<String, Object> entry : windowContext.getParams().entrySet()) {
                templateParams.put(paramPerfix + entry.getKey(), entry.getValue());
            }
        }
    }
    String sessionPrefix = ParameterInfo.Type.SESSION.getPrefix() + "$";
    templateParams.put(sessionPrefix + "userId", userSession.getCurrentOrSubstitutedUser().getId());
    templateParams.put(sessionPrefix + "userLogin", userSession.getCurrentOrSubstitutedUser().getLoginLowerCase());
    for (String name : userSession.getAttributeNames()) {
        templateParams.put(sessionPrefix + name, userSession.getAttribute(name));
    }
    return templateParams;
}
Also used : FrameContext(com.haulmont.cuba.gui.FrameContext) ParameterInfo(com.haulmont.cuba.core.global.filter.ParameterInfo)

Example 2 with FrameContext

use of com.haulmont.cuba.gui.FrameContext in project cuba by cuba-platform.

the class AbstractCollectionDatasource method getLoggingTag.

protected String getLoggingTag(String prefix) {
    String windowId = "";
    if (dsContext != null) {
        FrameContext windowContext = dsContext.getFrameContext();
        if (windowContext != null) {
            Frame frame = windowContext.getFrame();
            if (frame != null) {
                windowId = ComponentsHelper.getFullFrameId(windowContext.getFrame());
            }
        }
    }
    String tag = prefix + " " + id;
    if (StringUtils.isNotBlank(windowId))
        tag = windowId + "@" + id;
    return tag;
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame) FrameContext(com.haulmont.cuba.gui.FrameContext)

Aggregations

FrameContext (com.haulmont.cuba.gui.FrameContext)2 ParameterInfo (com.haulmont.cuba.core.global.filter.ParameterInfo)1 Frame (com.haulmont.cuba.gui.components.Frame)1