Author: lektran
Date: Sat Apr 3 17:11:34 2010
New Revision: 930544
URL: http://svn.apache.org/viewvc?rev=930544&view=rev
Log:
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.
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java?rev=930544&r1=930543&r2=930544&view=diff
==============================================================================
---
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java
(original)
+++
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java
Sat Apr 3 17:11:34 2010
@@ -71,6 +71,7 @@ public class ContentMapFacade implements
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
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
// 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);
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java?rev=930544&r1=930543&r2=930544&view=diff
==============================================================================
---
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
(original)
+++
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
Sat Apr 3 17:11:34 2010
@@ -219,6 +219,11 @@ public class ContentWorker implements or
// 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 or
// 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