From 4b032062929bb486fea1f237e22ffb581df3da85 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Fri, 13 Jul 2007 13:31:48 +0000 Subject: [PATCH] A 1st patch (htmlwidget.patch 2 kb)from Adriam Crum "Make OFBiz more dial-up friendly" (https://issues.apache.org/jira/browse/OFBIZ-642) git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@555988 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/ofbiz/widget/screen/HtmlWidget.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java b/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java index 99994a85fc..b2953b0baf 100644 --- a/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java +++ b/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java @@ -35,6 +35,8 @@ import org.ofbiz.base.util.template.FreeMarkerWorker; import org.w3c.dom.Element; import freemarker.template.TemplateException; +import freemarker.template.TemplateModelException; +import freemarker.template.utility.StandardCompress; /** * Widget Library - Screen model HTML class @@ -73,8 +75,18 @@ public class HtmlWidget extends ModelScreenWidget { //Debug.logInfo("Rendering template at location [" + location + "] with context: \n" + context, module); if (location.endsWith(".ftl")) { + StandardCompress compress = new StandardCompress(); + String compressHTML = null; + Map parametersMap = (Map) context.get("parameters"); + if (parametersMap != null) { + compressHTML = (String) parametersMap.get("compressHTML"); + } try { - FreeMarkerWorker.renderTemplateAtLocation(location, context, writer); + if ("true".equals(compressHTML)) { + FreeMarkerWorker.renderTemplateAtLocation(location, context, compress.getWriter(writer, null)); + } else { + FreeMarkerWorker.renderTemplateAtLocation(location, context, writer); + } } catch (MalformedURLException e) { String errMsg = "Error rendering included template at location [" + location + "]: " + e.toString(); Debug.logError(e, errMsg, module); @@ -92,7 +104,7 @@ public class HtmlWidget extends ModelScreenWidget { throw new IllegalArgumentException("Rending not yet support for the tempalte at location: " + location); } } - + public static class HtmlTemplate extends ModelScreenWidget { protected FlexibleStringExpander locationExdr; @@ -175,3 +187,5 @@ public class HtmlWidget extends ModelScreenWidget { } } + +