Search in sources :

Example 1 with IContentListWidgetHelper

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper in project entando-core by entando.

the class ContentListFilterTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    try {
        if (!this.isRightKey()) {
            StringBuilder message = new StringBuilder();
            for (int i = 0; i < IContentListWidgetHelper.allowedMetadataFilterKeys.length; i++) {
                if (i != 0) {
                    message.append(",");
                }
                message.append(IContentListWidgetHelper.allowedMetadataFilterKeys[i]);
            }
            throw new RuntimeException("The key '" + this.getKey() + "' is unknown; " + "Please use a valid one - " + message);
        }
        IContentListWidgetHelper helper = (IContentListWidgetHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_LIST_HELPER, this.pageContext);
        IContentListTagBean parent = (IContentListTagBean) findAncestorWithClass(this, IContentListTagBean.class);
        String contentType = parent.getContentType();
        EntitySearchFilter filter = helper.getFilter(contentType, (IEntityFilterBean) this, reqCtx);
        if (null != filter) {
            parent.addFilter(filter);
        }
    } catch (Throwable t) {
        _logger.error("error in end tag", t);
        throw new JspException("Tag error detected ", t);
    }
    return super.doEndTag();
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) IContentListWidgetHelper(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper) IContentListTagBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListTagBean) RequestContext(com.agiletec.aps.system.RequestContext) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 2 with IContentListWidgetHelper

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper in project entando-core by entando.

the class ContentListTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    try {
        IContentListWidgetHelper helper = (IContentListWidgetHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_LIST_HELPER, this.pageContext);
        List<UserFilterOptionBean> defaultUserFilterOptions = helper.getConfiguredUserFilters(this, reqCtx);
        this.addUserFilterOptions(defaultUserFilterOptions);
        this.extractExtraWidgetParameters(reqCtx);
        if (null != this.getUserFilterOptions() && null != this.getUserFilterOptionsVar()) {
            this.pageContext.setAttribute(this.getUserFilterOptionsVar(), this.getUserFilterOptions());
        }
        List<String> contents = this.getContentsId(helper, reqCtx);
        this.pageContext.setAttribute(this.getListName(), contents);
    } catch (Throwable t) {
        _logger.error("error in end tag", t);
        throw new JspException("Error detected while finalising the tag", t);
    }
    this.release();
    return EVAL_PAGE;
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) IContentListWidgetHelper(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper) UserFilterOptionBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean) RequestContext(com.agiletec.aps.system.RequestContext)

Example 3 with IContentListWidgetHelper

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper in project entando-core by entando.

the class ContentListUserFilterOptionTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    try {
        if (!this.isRightKey()) {
            StringBuilder message = new StringBuilder();
            for (int i = 0; i < IContentListWidgetHelper.allowedMetadataUserFilterOptionKeys.length; i++) {
                if (i != 0)
                    message.append(",");
                message.append(IContentListWidgetHelper.allowedMetadataUserFilterOptionKeys[i]);
            }
            throw new RuntimeException("The key '" + this.getKey() + "' is unknown; " + "Please use a valid one - " + message);
        }
        IContentListWidgetHelper helper = (IContentListWidgetHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_LIST_HELPER, this.pageContext);
        IContentListTagBean parent = (IContentListTagBean) findAncestorWithClass(this, IContentListTagBean.class);
        String contentType = parent.getContentType();
        UserFilterOptionBean filter = helper.getUserFilterOption(contentType, this, reqCtx);
        if (null != filter) {
            parent.addUserFilterOption(filter);
        }
    } catch (Throwable t) {
        _logger.error("error in do end tag", t);
        // ApsSystemUtils.logThrowable(t, this, "doEndTag");
        throw new JspException("Tag error detected ", t);
    }
    return super.doEndTag();
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) IContentListWidgetHelper(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper) IContentListTagBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListTagBean) UserFilterOptionBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean) RequestContext(com.agiletec.aps.system.RequestContext)

Aggregations

RequestContext (com.agiletec.aps.system.RequestContext)3 IContentListWidgetHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper)3 ServletRequest (javax.servlet.ServletRequest)3 JspException (javax.servlet.jsp.JspException)3 IContentListTagBean (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListTagBean)2 UserFilterOptionBean (com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean)2 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)1