diff --git a/webapp/config/web.xml b/webapp/config/web.xml
index 512a86899..e5339d4d1 100644
--- a/webapp/config/web.xml
+++ b/webapp/config/web.xml
@@ -299,6 +299,15 @@
/about
+
+ FreeMarkerTestController
+ edu.cornell.mannlib.vitro.webapp.controller.freemarker.TestController
+
+
+ FreeMarkerTestController
+ /freemarkertest
+
+
FakeSelfEditController
edu.cornell.mannlib.vitro.webapp.controller.FakeSelfEditController
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/AboutController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/AboutController.java
index 96ebcd2db..8eb77e674 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/AboutController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/AboutController.java
@@ -2,9 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
@@ -25,13 +23,6 @@ public class AboutController extends FreeMarkerHttpServlet {
body.put("aboutText", portal.getAboutText());
body.put("acknowledgeText", portal.getAcknowledgeText());
-
- // Test of #list directive in template on undefined, null, or empty values
- // Basic idea: empty list okay, null or undefined value not okay
- // List apples = new ArrayList(); // no error
- // List apples = null; // error
- // body.put("apples", apples);
- // no apples in body: error
String bodyTemplate = "about.ftl";
return mergeBodyToTemplate(bodyTemplate, body);
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreeMarkerSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreeMarkerSetup.java
index fc37d9265..aed8a75bc 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreeMarkerSetup.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreeMarkerSetup.java
@@ -28,20 +28,34 @@ public class FreeMarkerSetup implements ServletContextListener {
// Specify the data source where the template files come from.
// RY Now being done for each request, in order to support multi-portal apps
// and dynamic theme-loading.
-// try {
-// cfg.setDirectoryForTemplateLoading(new File(templatePath));
-// } catch (IOException e) {
-// log.error("Error specifying template directory.");
-// }
+ // try {
+ // cfg.setDirectoryForTemplateLoading(new File(templatePath));
+ // } catch (IOException e) {
+ // log.error("Error specifying template directory.");
+ // }
String buildEnv = ConfigurationProperties.getProperty("Environment.build");
if (buildEnv != null && buildEnv.equals("development")) {
cfg.setTemplateUpdateDelay(0); // no template caching in development
}
- // Specify how templates will see the data-model. This is an advanced topic...
- // but just use this:
- cfg.setObjectWrapper(new DefaultObjectWrapper());
+ // Specify how templates will see the data-model. This is an advanced topic...
+ // but just use this:
+ cfg.setObjectWrapper(new DefaultObjectWrapper());
+
+
+ // Set some formatting defaults. These can be overridden at the template
+ // or environment (template-processing) level, or for an individual
+ // instance by using built-ins.
+ cfg.setLocale(java.util.Locale.US);
+
+ String dateFormat = "M/d/yyyy";
+ cfg.setDateFormat(dateFormat);
+ String timeFormat = "hh:mm a";
+ cfg.setTimeFormat(timeFormat);
+ cfg.setDateTimeFormat(dateFormat + " " + timeFormat);
+
+ //cfg.setNumberFormat("#,##0.##");
try {
cfg.setSetting("url_escaping_charset", "ISO-8859-1");
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TestController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TestController.java
new file mode 100644
index 000000000..3544267c6
--- /dev/null
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/TestController.java
@@ -0,0 +1,47 @@
+/* $This file is distributed under the terms of the license in /doc/license.txt$ */
+
+package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A place for storing test cases.
+ * @author rjy7
+ *
+ */
+public class TestController extends FreeMarkerHttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String getTitle() {
+ return "Test";
+ }
+
+ protected String getBody() {
+
+ Map body = new HashMap();
+
+ // Test of #list directive in template on undefined, null, and empty values.
+ // Basic idea: empty list okay, null or undefined value not okay.
+ List apples = new ArrayList(); // no error
+ // List apples = null; // error
+ body.put("apples", apples); // without this: error
+
+ Calendar cal = Calendar.getInstance();
+ Date now = cal.getTime();
+ body.put("now", now);
+ // In template: ${now?date}, ${now?datetime}, ${now?time}
+
+ // Create the template to see the examples live.
+ String bodyTemplate = "test.ftl";
+ return mergeBodyToTemplate(bodyTemplate, body);
+
+ }
+
+}
+
diff --git a/webapp/web/templates/freemarker/body/test.ftl b/webapp/web/templates/freemarker/body/test.ftl
new file mode 100644
index 000000000..1d9d898fd
--- /dev/null
+++ b/webapp/web/templates/freemarker/body/test.ftl
@@ -0,0 +1,15 @@
+<#-- $This file is distributed under the terms of the license in /doc/license.txt -->
+
+<#-- FreeMarker test cases -->
+
+Dates
+
+${now?datetime}
+${now?date}
+${now?time}
+
+Apples
+
+<#list apples as apple>
+ ${apple}
+#list>
\ No newline at end of file