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;
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations