Search in sources :

Example 16 with RequestContext

use of com.agiletec.aps.system.RequestContext 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 17 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class CurrentWidgetTag method extractTitle.

private String extractTitle(Widget widget) {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
    WidgetType type = widget.getType();
    String value = type.getTitles().getProperty(currentLang.getCode());
    if (null == value || value.trim().length() == 0) {
        ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
        Lang defaultLang = langManager.getDefaultLang();
        value = type.getTitles().getProperty(defaultLang.getCode());
    }
    return value;
}
Also used : ServletRequest(javax.servlet.ServletRequest) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) Lang(com.agiletec.aps.system.services.lang.Lang) RequestContext(com.agiletec.aps.system.RequestContext) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 18 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class InfoTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    try {
        if ("startLang".equals(this._key)) {
            Lang startLang = this.extractStartLang();
            this._info = startLang.getCode();
        } else if ("defaultLang".equals(this._key)) {
            ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
            this._info = langManager.getDefaultLang().getCode();
        } else if ("currentLang".equals(this._key)) {
            RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
            Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
            this._info = currentLang.getCode();
        } else if ("langs".equals(this._key)) {
            ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
            this._info = langManager.getLangs();
        } else if ("systemParam".equals(this._key)) {
            if (SystemConstants.PAR_APPL_BASE_URL.equals(this.getParamName())) {
                IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.pageContext);
                this._info = urlManager.getApplicationBaseURL((HttpServletRequest) request);
            } else {
                ConfigInterface confManager = (ConfigInterface) ApsWebApplicationUtils.getBean(SystemConstants.BASE_CONFIG_MANAGER, this.pageContext);
                this._info = confManager.getParam(this.getParamName());
            }
        }
    } catch (Throwable t) {
        _logger.error("Error during tag initialization", t);
        throw new JspException("Error during tag initialization", t);
    }
    return EVAL_BODY_INCLUDE;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) IURLManager(com.agiletec.aps.system.services.url.IURLManager) Lang(com.agiletec.aps.system.services.lang.Lang) ConfigInterface(com.agiletec.aps.system.services.baseconfig.ConfigInterface) RequestContext(com.agiletec.aps.system.RequestContext)

Example 19 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class InternalServletTag method buildWidgetOutput.

protected String buildWidgetOutput(IPage page, ResponseWrapper responseWrapper) throws JspException {
    String output = null;
    ServletRequest req = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
    try {
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        this.includeWidget(reqCtx, responseWrapper, widget);
        Cookie[] cookies = responseWrapper.getCookiesToAdd();
        if (null != cookies) {
            for (int i = 0; i < cookies.length; i++) {
                Cookie cookie = cookies[i];
                cookie.setHttpOnly(true);
                reqCtx.getResponse().addCookie(cookie);
            }
        }
        output = responseWrapper.toString();
        responseWrapper.getWriter().close();
    } catch (Throwable t) {
        String msg = "Error building widget output";
        throw new JspException(msg, t);
    }
    return output;
}
Also used : Cookie(javax.servlet.http.Cookie) ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) Widget(com.agiletec.aps.system.services.page.Widget) RequestContext(com.agiletec.aps.system.RequestContext)

Example 20 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class URLTag method doStartTag.

/**
 * Prepares a PageURL object; this object may comprehend several sub-tags
 */
@Override
public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    try {
        IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.pageContext);
        this._pageUrl = urlManager.createURL(reqCtx);
        if (_pageCode != null) {
            _pageUrl.setPageCode(_pageCode);
        }
        if (_langCode != null) {
            _pageUrl.setLangCode(_langCode);
        }
        if (this.isParamRepeat()) {
            List<String> exclusion = this.getParametersToExclude();
            _pageUrl.setParamRepeat(exclusion);
        }
    } catch (Throwable t) {
        _logger.error("Error during tag initialization", t);
        throw new JspException("Error during tag initialization", t);
    }
    return EVAL_BODY_INCLUDE;
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) IURLManager(com.agiletec.aps.system.services.url.IURLManager) RequestContext(com.agiletec.aps.system.RequestContext)

Aggregations

RequestContext (com.agiletec.aps.system.RequestContext)89 ServletRequest (javax.servlet.ServletRequest)25 JspException (javax.servlet.jsp.JspException)22 IPage (com.agiletec.aps.system.services.page.IPage)15 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)12 Lang (com.agiletec.aps.system.services.lang.Lang)10 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 Widget (com.agiletec.aps.system.services.page.Widget)5 NavigatorTarget (com.agiletec.aps.system.services.page.widget.NavigatorTarget)5 IURLManager (com.agiletec.aps.system.services.url.IURLManager)5 ContentRenderizationInfo (com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo)5 DataObjectRenderizationInfo (org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo)5 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)4 UserDetails (com.agiletec.aps.system.services.user.UserDetails)4 ControllerManager (com.agiletec.aps.system.services.controller.ControllerManager)3 HeadInfoContainer (com.agiletec.aps.tags.util.HeadInfoContainer)3 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)3 IContentListWidgetHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper)3 IContentViewerHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper)3