Author: byersa
Date: Fri Sep 28 02:22:37 2007
New Revision: 580264
URL: http://svn.apache.org/viewvc?rev=580264&view=rev
Log:
Adding some fixes to this work-in-progress
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java?rev=580264&r1=580263&r2=580264&view=diff
==============================================================================
---
ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java
(original)
+++
ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java
Fri Sep 28 02:22:37 2007
@@ -53,6 +53,8 @@
public class RenderContentAndSubContent implements TemplateTransformModel {
public static final String module =
RenderContentAndSubContent.class.getName();
+// public static final String [] upSaveKeyNames = {"globalNodeTrail"};
+// public static final String [] saveKeyNames = {"contentId",
"subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale",
"wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
public Writer getWriter(final Writer out, Map args) {
final Environment env = Environment.getCurrentEnvironment();
@@ -61,11 +63,16 @@
final HttpServletRequest request = (HttpServletRequest)
FreeMarkerWorker.getWrappedObject("request", env);
final HttpServletResponse response = (HttpServletResponse)
FreeMarkerWorker.getWrappedObject("response", env);
final Map envMap = FreeMarkerWorker.createEnvironmentMap(env);
- final Map templateRoot = MapStack.create(envMap);
+ final Map templateRoot = MapStack.create();
+ ((MapStack)templateRoot).push(envMap);
if (Debug.verboseOn()) Debug.logVerbose("in
RenderContentAndSubContent, contentId(0):" + templateRoot.get("contentId"),
module);
FreeMarkerWorker.getSiteParameters(request, templateRoot);
+// final Map savedValuesUp = new HashMap();
+ //FreeMarkerWorker.saveContextValues(templateRoot, upSaveKeyNames,
savedValuesUp);
FreeMarkerWorker.overrideWithArgs(templateRoot, args);
+ final Map savedValues = new HashMap();
+
return new Writer(out) {
public void write(char cbuf[], int off, int len) {
@@ -97,21 +104,32 @@
String contentId =
(String)templateRoot.get("contentId");
String mapKey = (String)templateRoot.get("mapKey");
String contentAssocTypeId =
(String)templateRoot.get("contentAssocTypeId");
- if (UtilValidate.isNotEmpty(mapKey) ||
UtilValidate.isNotEmpty(mapKey)) {
- List assocList = null;
- if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
- assocList =
UtilMisc.toList(contentAssocTypeId);
- }
- GenericValue content =
ContentWorker.getSubContent(delegator, contentId, mapKey, null, null,
assocList, null);
- if (content != null) {
- contentId = content.getString("contentId");
- } else {
- contentId = null;
- }
- }
- if (contentId != null) {
+ if (UtilValidate.isNotEmpty(mapKey) ||
UtilValidate.isNotEmpty(contentAssocTypeId)) {
+ String txt =
ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, mapKey,
templateRoot, locale, mimeTypeId, true);
+ //String txt =
ContentWorker.renderSubContentAsTextCache(delegator, thisContentId, thisMapKey,
null, templateRoot, locale, mimeTypeId, null, fromDate);
+// if ("true".equals(xmlEscape)) {
+// txt = UtilFormatOut.encodeXmlValue(txt);
+// }
+
+ out.write(txt);
+
+// if (Debug.infoOn()) Debug.logInfo("in
RenderSubContent, after renderContentAsTextCache:", module);
+// List assocList = null;
+// if (UtilValidate.isNotEmpty(contentAssocTypeId))
{
+// assocList =
UtilMisc.toList(contentAssocTypeId);
+// }
+// GenericValue content =
ContentWorker.getSubContent(delegator, contentId, mapKey, null, null,
assocList, null);
+// if (content != null) {
+// contentId = content.getString("contentId");
+// } else {
+// contentId = null;
+// }
+ } else if (contentId != null) {
ContentWorker.renderContentAsText(dispatcher,
delegator, contentId, out, templateRoot, locale, mimeTypeId, true);
+// ((MapStack)templateRoot).pop();
}
+ //FreeMarkerWorker.reloadValues(templateRoot,
savedValues, env);
+ //FreeMarkerWorker.reloadValues(templateRoot,
savedValuesUp, env);
} catch (GeneralException e) {
String errMsg = "Error rendering thisContentId:" +
(String)templateRoot.get("contentId") + " msg:" + e.toString();