Skip to content

Commit

Permalink
Upgrade to the most recent version of Freemarker-2.3-gae: this is not…
Browse files Browse the repository at this point in the history
… an official release yet but it will be soon; I have committed this work, as discussed in the dev list, in order to get help from the community to test this new improved version of Freemarker and provide feedback to the Freemarker community.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1605029 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
jacopoc committed Jun 24, 2014
1 parent 2f19b7e commit a02c680
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<classpathentry kind="lib" path="framework/base/lib/clhm-release-1.0-lru.jar"/>
<classpathentry kind="lib" path="framework/base/lib/hamcrest-all-1.2.jar"/>
<classpathentry kind="lib" path="framework/base/lib/fop-1.1.jar"/>
<classpathentry kind="lib" path="framework/base/lib/freemarker-2.3.19-null-wildcards.jar"/>
<classpathentry kind="lib" path="framework/base/lib/freemarker-2.3-gae-d4ffa9e3727b83b95fd546591aa15dbad0118bd0.jar"/>
<classpathentry kind="lib" path="framework/base/lib/httpclient-4.2.1.jar"/>
<classpathentry kind="lib" path="framework/base/lib/httpclient-cache-4.2.1.jar"/>
<classpathentry kind="lib" path="framework/base/lib/httpcore-4.2.1.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ BSD License:
applications/content/lib/dom4j-1.6.1.jar
framework/base/lib/antisamy-bin.1.2.jar
framework/base/lib/bsh-engine-modified.jar
framework/base/lib/freemarker-2.3.19-null-wildcards.jar
framework/base/lib/freemarker-2.3-gae-d4ffa9e3727b83b95fd546591aa15dbad0118bd0.jar
framework/base/lib/hamcrest-all-1.2.jar
framework/base/lib/httpunit-1.7.jar
framework/base/lib/ical4j-1.0-rc2.jar
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import freemarker.template.TemplateExceptionHandler;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import freemarker.template.Version;

/** FreeMarkerWorker - Freemarker Template Engine Utilities.
*
Expand All @@ -74,22 +75,23 @@ public class FreeMarkerWorker {

public static final String module = FreeMarkerWorker.class.getName();

public static final Version version = new Version(2, 3, 21);

// use soft references for this so that things from Content records don't kill all of our memory, or maybe not for performance reasons... hmmm, leave to config file...
private static final UtilCache<String, Template> cachedTemplates = UtilCache.createUtilCache("template.ftl.general", 0, 0, false);
private static final BeansWrapper defaultOfbizWrapper = configureBeansWrapper(new BeansWrapper());
private static final BeansWrapper defaultOfbizWrapper = configureBeansWrapper(new BeansWrapper(version));
private static final Configuration defaultOfbizConfig = makeConfiguration(defaultOfbizWrapper);

public static BeansWrapper getDefaultOfbizWrapper() {
return defaultOfbizWrapper;
}

public static <T extends BeansWrapper> T configureBeansWrapper(T wrapper) {
wrapper.setNullWildcards(true);
return wrapper;
}

public static Configuration makeConfiguration(BeansWrapper wrapper) {
Configuration newConfig = new Configuration();
Configuration newConfig = new Configuration(version);

newConfig.setObjectWrapper(wrapper);
newConfig.setSharedVariable("Static", wrapper.getStaticModels());
Expand Down
7 changes: 6 additions & 1 deletion framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import freemarker.template.Version;

/**
* Widget Library - Screen model HTML class.
Expand All @@ -58,10 +59,14 @@ public class HtmlWidget extends ModelScreenWidget {
public static final String module = HtmlWidget.class.getName();

private static final UtilCache<String, Template> specialTemplateCache = UtilCache.createUtilCache("widget.screen.template.ftl.general", 0, 0, false);
protected static Configuration specialConfig = FreeMarkerWorker.makeConfiguration(FreeMarkerWorker.configureBeansWrapper(new ExtendedWrapper()));
protected static Configuration specialConfig = FreeMarkerWorker.makeConfiguration(FreeMarkerWorker.configureBeansWrapper(new ExtendedWrapper(FreeMarkerWorker.version)));

// not sure if this is the best way to get FTL to use my fancy MapModel derivative, but should work at least...
public static class ExtendedWrapper extends BeansWrapper {
public ExtendedWrapper(Version version) {
super(version);
}

@SuppressWarnings("unchecked")
@Override
public TemplateModel wrap(Object object) throws TemplateModelException {
Expand Down

0 comments on commit a02c680

Please sign in to comment.