use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class I18nTag method doEndTag.
@Override
public int doEndTag() throws JspException {
RequestContext reqCtx = (RequestContext) this.pageContext.getRequest().getAttribute(RequestContext.REQCTX);
try {
Lang currentLang = null;
if (reqCtx != null) {
currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
} else {
ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
currentLang = langManager.getDefaultLang();
}
String label = this.extractLabel(currentLang);
if (this._varName != null) {
this.pageContext.setAttribute(this._varName, label);
} else {
if (this.getEscapeXml()) {
out(this.pageContext, this.getEscapeXml(), label);
} else {
this.pageContext.getOut().print(label);
}
}
} catch (Throwable t) {
_logger.error("Error during tag initialization", t);
throw new JspException("Error during tag initialization", t);
}
return super.doStartTag();
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class InternalServletTag method doEndTag.
/**
* Invokes the widget configured in the current page.
*
* @throws JspException in case of error that occurred in both this method
* or in one of the included JSPs
*/
@Override
public int doEndTag() throws JspException {
int result = super.doEndTag();
ServletRequest req = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
try {
IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
ResponseWrapper responseWrapper = new ResponseWrapper((HttpServletResponse) this.pageContext.getResponse());
String output = this.buildWidgetOutput(page, responseWrapper);
if (responseWrapper.isRedirected()) {
String redirect = responseWrapper.getRedirectPath();
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_EXTERNAL_REDIRECT, redirect);
result = SKIP_PAGE;
} else {
this.pageContext.getOut().print(output);
}
} catch (Throwable t) {
_logger.error("Error in widget preprocessing", t);
String msg = "Error in widget preprocessing";
throw new JspException(msg, t);
}
return result;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class PageInfoTag method doEndTag.
@Override
public int doEndTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
try {
IPageManager pageManager = (IPageManager) ApsWebApplicationUtils.getBean(SystemConstants.PAGE_MANAGER, this.pageContext);
IPage page = pageManager.getOnlinePage(this.getPageCode());
if (null == page) {
_logger.error("Required info for null page : inserted code '{}'", this.getPageCode());
}
if (this.getInfo() == null || this.getInfo().equals(CODE_INFO)) {
this.setValue(page.getCode());
} else if (this.getInfo().equals(TITLE_INFO)) {
this.extractPageTitle(page, currentLang);
} else if (this.getInfo().equals(URL_INFO)) {
this.extractPageUrl(page, currentLang, reqCtx);
} else if (this.getInfo().equals(OWNER_INFO)) {
this.extractPageOwner(page, reqCtx);
} else if (this.getInfo().equals(CHILD_OF_INFO)) {
this.extractIsChildOfTarget(page);
} else if (this.getInfo().equals(HAS_CHILD)) {
boolean hasChild = (page.getChildrenCodes() != null && page.getChildrenCodes().length > 0);
this._value = new Boolean(hasChild).toString();
}
this.evalValue();
} catch (Throwable t) {
_logger.error("Error during tag initialization", t);
// ApsSystemUtils.logThrowable(t, this, "doStartTag");
throw new JspException("Error during tag initialization ", t);
}
this.release();
return EVAL_PAGE;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class PagerTagHelper method getMaxElementForItem.
protected int getMaxElementForItem(int maxItems, ServletRequest request) {
if (maxItems == 0) {
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
if (reqCtx != null) {
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties config = widget.getConfig();
String stringMax = (null != config) ? (String) config.get("maxElemForItem") : null;
if (stringMax != null && stringMax.length() > 0) {
maxItems = Integer.parseInt(stringMax);
}
}
}
return maxItems;
}
Aggregations