Author: jleroux
Date: Sun Oct 3 10:03:14 2010
New Revision: 1003943
URL: http://svn.apache.org/viewvc?rev=1003943&view=rev
Log:
A patch from Sascha Rodekamp "Additional parameter for FreeMarker to tell if it
should load ftl files from cache or not"
(https://issues.apache.org/jira/browse/OFBIZ-3970) - OFBIZ-3970
This patch allows you to tell FreeMarker if it should load the ftl files from
cache or not as extension for the method
description. If you have a few screens which shouldn't use the cache you can
configure them separately. The use case is loading
content with templates which are stored in the DB and can be modified during
the runtime (CMS).
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=1003943&r1=1003942&r2=1003943&view=diff
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java
(original) +++
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java
Sun Oct 3 10:03:14 2010 @@ -155,10 +155,22 @@
public class FreeMarkerWorker {
* @param outWriter The Writer to render to
*/
public static void renderTemplate(String templateLocation, String templateString,
Map<String, Object> context, Appendable
outWriter) throws TemplateException, IOException { +
renderTemplate(templateLocation, templateString, context, outWriter,
true); + }
+
+ /**
+ * Renders a template contained in a String.
+ * @param templateLocation A unique ID for this template - used for caching
+ * @param templateString The String containing the template
+ * @param context The context Map
+ * @param outWriter The Writer to render to
+ * @param useCache try to get template from cache
+ */
+ public static void renderTemplate(String templateLocation, String
templateString, Map<String, Object> context, Appendable
outWriter, boolean useCache) throws TemplateException, IOException { if
(UtilValidate.isEmpty(templateString)) {
renderTemplate(templateLocation, context, outWriter);
} else {
- renderTemplateFromString(templateString, templateLocation,
context, outWriter);
+ renderTemplateFromString(templateString, templateLocation,
context, outWriter, useCache);
}
}
@@ -167,34 +179,46 @@ public class FreeMarkerWorker {
* @param templateLocation A unique ID for this template - used for caching
* @param context The context Map
* @param outWriter The Writer to render to
+ * @param useCache try to get template from cache
*/
public static void renderTemplate(String templateLocation, Map<String,
Object> context, Appendable outWriter) throws
TemplateException, IOException { Template template =
getTemplate(templateLocation);
renderTemplate(template, context, outWriter);
}
- public static void clearTemplateFromCache(String templateLocation) {
- synchronized (cachedTemplates) {
- cachedTemplates.remove(templateLocation);
- }
- }
- public static Environment renderTemplateFromString(String templateString, String
templateLocation, Map<String, Object>
context, Appendable outWriter) throws TemplateException, IOException {
- Template template = cachedTemplates.get(templateLocation);