Search in sources :

Example 1 with HeadInfoContainer

use of com.agiletec.aps.tags.util.HeadInfoContainer in project entando-core by entando.

the class CheckHeadInfoOutputterTag method doStartTag.

public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    HeadInfoContainer headInfo = (HeadInfoContainer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_HEAD_INFO_CONTAINER);
    List<Object> infos = headInfo.getInfos(this.getType());
    if (infos == null || infos.size() == 0) {
        return SKIP_BODY;
    } else {
        return EVAL_BODY_INCLUDE;
    }
}
Also used : ServletRequest(javax.servlet.ServletRequest) HeadInfoContainer(com.agiletec.aps.tags.util.HeadInfoContainer) RequestContext(com.agiletec.aps.system.RequestContext)

Example 2 with HeadInfoContainer

use of com.agiletec.aps.tags.util.HeadInfoContainer in project entando-core by entando.

the class HeadInfoOutputterTag method doStartTag.

public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    HeadInfoContainer headInfo = (HeadInfoContainer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_HEAD_INFO_CONTAINER);
    int retVal;
    List<Object> infos = headInfo.getInfos(this.getType());
    if (infos != null) {
        this._infos = infos;
        this._index = 0;
        retVal = EVAL_BODY_INCLUDE;
    } else {
        retVal = SKIP_BODY;
    }
    return retVal;
}
Also used : ServletRequest(javax.servlet.ServletRequest) HeadInfoContainer(com.agiletec.aps.tags.util.HeadInfoContainer) RequestContext(com.agiletec.aps.system.RequestContext)

Example 3 with HeadInfoContainer

use of com.agiletec.aps.tags.util.HeadInfoContainer in project entando-core by entando.

the class HeadInfoTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    try {
        HeadInfoContainer headInfo = (HeadInfoContainer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_HEAD_INFO_CONTAINER);
        if (_type != null && (_info != null || _var != null)) {
            Object info = _info;
            if (_info != null) {
                info = _info;
            } else {
                info = this.extractAttribute();
            }
            headInfo.addInfo(_type, info);
        }
    } catch (Throwable t) {
        _logger.error("Error closing tag", t);
        throw new JspException("Error closing tag ", t);
    }
    return super.doEndTag();
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) HeadInfoContainer(com.agiletec.aps.tags.util.HeadInfoContainer) RequestContext(com.agiletec.aps.system.RequestContext)

Example 4 with HeadInfoContainer

use of com.agiletec.aps.tags.util.HeadInfoContainer in project entando-core by entando.

the class WidgetExecutorService method service.

@Override
public void service(RequestContext reqCtx) {
    try {
        reqCtx.addExtraParam(SystemConstants.EXTRAPAR_HEAD_INFO_CONTAINER, new HeadInfoContainer());
        IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
        String[] widgetOutput = new String[page.getWidgets().length];
        reqCtx.addExtraParam("ShowletOutput", widgetOutput);
        this.buildWidgetsOutput(reqCtx, page, widgetOutput);
        String redirect = (String) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_EXTERNAL_REDIRECT);
        if (null != redirect) {
            HttpServletResponse response = (HttpServletResponse) reqCtx.getResponse();
            response.sendRedirect(redirect);
            return;
        }
    } catch (Throwable t) {
        String msg = "Error detected during widget preprocessing";
        _logger.error(msg, t);
        throw new RuntimeException(msg, t);
    }
    return;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) HeadInfoContainer(com.agiletec.aps.tags.util.HeadInfoContainer) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Aggregations

HeadInfoContainer (com.agiletec.aps.tags.util.HeadInfoContainer)4 RequestContext (com.agiletec.aps.system.RequestContext)3 ServletRequest (javax.servlet.ServletRequest)3 IPage (com.agiletec.aps.system.services.page.IPage)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 JspException (javax.servlet.jsp.JspException)1