Adding some fixes to this work-in-progress

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@580264 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alfred Maxwell Byers
2007-09-28 09:22:37 +00:00
parent d15624c691
commit 7f318b8913
@@ -53,6 +53,8 @@ import freemarker.template.TemplateTransformModel;
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 @@ public class RenderContentAndSubContent implements TemplateTransformModel {
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 @@ public class RenderContentAndSubContent implements TemplateTransformModel {
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();