use of com.agiletec.aps.system.RequestContext 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();
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class ContentTag method doStartTag.
@Override
public int doStartTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
try {
IContentViewerHelper helper = (IContentViewerHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_VIEWER_HELPER, this.pageContext);
String contentId = (this.getContentId() != null && this.getContentId().trim().length() > 0) ? this.getContentId() : null;
ContentRenderizationInfo renderInfo = helper.getRenderizationInfo(contentId, this.getModelId(), this.isPublishExtraTitle(), reqCtx);
String renderedContent = (null != renderInfo) ? renderInfo.getRenderedContent() : "";
if (null != this.getVar()) {
this.pageContext.setAttribute(this.getVar(), renderedContent);
} else {
this.pageContext.getOut().print(renderedContent);
}
if (null != renderInfo && null != this.getAttributeValuesByRoleVar()) {
this.pageContext.setAttribute(this.getAttributeValuesByRoleVar(), renderInfo.getAttributeValues());
}
} catch (Throwable t) {
_logger.error("error in doStartTag", t);
throw new JspException("Error detected while initialising the tag", t);
}
return EVAL_PAGE;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class SearcherTag method doStartTag.
@Override
public int doStartTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
try {
String word = request.getParameter("search");
SearcherTagHelper helper = new SearcherTagHelper();
List<String> result = helper.executeSearch(word, reqCtx);
this.pageContext.setAttribute(this.getListName(), result);
request.setAttribute("search", word);
} catch (Throwable t) {
_logger.error("error in do start tag", t);
// ApsSystemUtils.logThrowable(e, this, "doStartTag");
throw new JspException("Error detected while initialising the tag", t);
}
return SKIP_BODY;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestContentListHelper method valueRequestContext.
private RequestContext valueRequestContext(String pageCode, int frame) throws Throwable {
RequestContext reqCtx = this.getRequestContext();
try {
Widget widgetToAdd = this.getShowletForTest("content_viewer_list", null);
this.setPageWidgets(pageCode, frame, widgetToAdd);
IPage page = this._pageManager.getOnlinePage(pageCode);
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, page);
Widget widget = page.getWidgets()[frame];
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME, new Integer(frame));
} catch (Throwable t) {
this.setPageWidgets(pageCode, frame, null);
throw t;
}
return reqCtx;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestContentListHelper method testGetContents_1.
public void testGetContents_1() throws Throwable {
String pageCode = "pagina_1";
int frame = 1;
try {
this.setUserOnSession("guest");
RequestContext reqCtx = this.valueRequestContext(pageCode, frame);
MockContentListTagBean bean = new MockContentListTagBean();
bean.setContentType("EVN");
EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true);
filter.setOrder(EntitySearchFilter.DESC_ORDER);
bean.addFilter(filter);
List<String> contents = this._helper.getContentsId(bean, reqCtx);
String[] expected = { "EVN194", "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
assertEquals(expected.length, contents.size());
for (int i = 0; i < expected.length; i++) {
assertEquals(expected[i], contents.get(i));
}
} catch (Throwable t) {
throw t;
} finally {
this.setPageWidgets(pageCode, frame, null);
}
}
Aggregations