Improved the content rendering so that multiple levels of decoration are supported, previously you could have only one content and it's decorator, anything above that and the contents being decorated would get lost in the rendering logic.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@930544 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Scott Gray
2010-04-03 17:11:34 +00:00
parent 82c5c4efc7
commit 25c3f11822
2 changed files with 14 additions and 0 deletions
@@ -71,6 +71,7 @@ public class ContentMapFacade implements Map {
protected final boolean cache;
protected boolean allowRender = true;
protected boolean isDecorated = false;
protected ContentMapFacade decoratedContent = null;
// internal objects
private String sortOrder="-fromDate";
@@ -207,6 +208,10 @@ public class ContentMapFacade implements Map {
this.subContent.setStatusFilter(obj);
}
public void setDecoratedContent(ContentMapFacade decoratedContent) {
this.decoratedContent = decoratedContent;
}
// implemented get method
public Object get(Object obj) {
if (!(obj instanceof String)) {
@@ -305,6 +310,9 @@ public class ContentMapFacade implements Map {
// TODO: change to use the MapStack instead of a cloned Map
Map renderCtx = FastMap.newInstance();
renderCtx.putAll(context);
if (this.decoratedContent != null) {
renderCtx.put("decoratedContent", decoratedContent);
}
if (this.isDecorated) {
renderCtx.put("_IS_DECORATED_", Boolean.TRUE);
@@ -219,6 +219,11 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface {
// create the content facade
ContentMapFacade facade = new ContentMapFacade(dispatcher, content, templateContext, locale, mimeTypeId, cache);
// If this content is decorating something then tell the facade about it in order to maintain the chain of decoration
ContentMapFacade decoratedContent = (ContentMapFacade) templateContext.get("decoratedContent");
if (decoratedContent != null) {
facade.setDecoratedContent(decoratedContent);
}
// look for a content decorator
String contentDecoratorId = content.getString("decoratorContentId");
@@ -244,6 +249,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface {
// render the decorator
ContentMapFacade decFacade = new ContentMapFacade(dispatcher, decorator, templateContext, locale, mimeTypeId, cache);
decFacade.setDecoratedContent(facade);
facade.setIsDecorated(true);
templateContext.put("decoratedContent", facade); // decorated content
templateContext.put("thisContent", decFacade); // decorator content