use of com.agiletec.aps.tags.util.IFrameDecoratorContainer in project entando-core by entando.
the class AbstractWidgetExecutorService method extractDecoratorsOutput.
protected String extractDecoratorsOutput(RequestContext reqCtx, Widget widget, List<IFrameDecoratorContainer> decorators, boolean isWidgetDecorator, boolean includeHeader) throws Throwable {
if (null == decorators || decorators.isEmpty()) {
return "";
}
StringBuilder builder = new StringBuilder();
for (int i = 0; i < decorators.size(); i++) {
IFrameDecoratorContainer decoratorContainer = (includeHeader) ? decorators.get(i) : decorators.get(decorators.size() - i - 1);
if ((isWidgetDecorator != decoratorContainer.isWidgetDecorator()) || !decoratorContainer.needsDecoration(widget, reqCtx)) {
continue;
}
String fragmentCode = (includeHeader) ? decoratorContainer.getHeaderFragmentCode() : decoratorContainer.getFooterFragmentCode();
String fragmentOutput = extractFragmentOutput(fragmentCode, reqCtx);
if (StringUtils.isNotBlank(fragmentCode)) {
builder.append(fragmentOutput);
} else {
String jspPath = (includeHeader) ? decoratorContainer.getHeaderJspPath() : decoratorContainer.getFooterJspPath();
if (StringUtils.isNotBlank(jspPath)) {
String output = extractJspOutput(reqCtx, jspPath);
builder.append(output);
}
}
}
return builder.toString();
}
use of com.agiletec.aps.tags.util.IFrameDecoratorContainer in project entando-core by entando.
the class AbstractWidgetExecutorService method buildWidgetsOutput.
protected void buildWidgetsOutput(RequestContext reqCtx, IPage page, String[] widgetOutput) throws ApsSystemException {
try {
List<IFrameDecoratorContainer> decorators = this.extractDecorators(reqCtx);
Widget[] widgets = page.getWidgets();
for (int frame = 0; frame < widgets.length; frame++) {
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME, new Integer(frame));
Widget widget = widgets[frame];
widgetOutput[frame] = this.buildWidgetOutput(reqCtx, widget, decorators);
}
} catch (Throwable t) {
String msg = "Error detected during widget preprocessing";
_logger.error(msg, t);
throw new ApsSystemException(msg, t);
}
}
use of com.agiletec.aps.tags.util.IFrameDecoratorContainer in project entando-core by entando.
the class AbstractWidgetExecutorService method extractDecorators.
protected List<IFrameDecoratorContainer> extractDecorators(RequestContext reqCtx) throws ApsSystemException {
HttpServletRequest request = reqCtx.getRequest();
WebApplicationContext wac = ApsWebApplicationUtils.getWebApplicationContext(request);
List<IFrameDecoratorContainer> containters = new ArrayList<IFrameDecoratorContainer>();
try {
String[] beanNames = wac.getBeanNamesForType(IFrameDecoratorContainer.class);
for (int i = 0; i < beanNames.length; i++) {
IFrameDecoratorContainer container = (IFrameDecoratorContainer) wac.getBean(beanNames[i]);
containters.add(container);
}
BeanComparator comparator = new BeanComparator("order");
Collections.sort(containters, comparator);
} catch (Throwable t) {
_logger.error("Error extracting widget decorators", t);
throw new ApsSystemException("Error extracting widget decorators", t);
}
return containters;
}
Aggregations