NIHVIVO-1992 Added current datetime value to page template map
This commit is contained in:
parent
95a4a6d008
commit
effce5b9db
3 changed files with 6 additions and 6 deletions
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -34,7 +35,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.BreadCrumbsUtil;
|
import edu.cornell.mannlib.vitro.webapp.web.BreadCrumbsUtil;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.PortalWebUtil;
|
import edu.cornell.mannlib.vitro.webapp.web.PortalWebUtil;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.functions.IndividualLocalNameMethod;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.User;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.User;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.files.Scripts;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.files.Scripts;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.files.Stylesheets;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.files.Stylesheets;
|
||||||
|
@ -405,6 +405,9 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
// Allow template to send domain name to JavaScript (needed for AJAX calls)
|
// Allow template to send domain name to JavaScript (needed for AJAX calls)
|
||||||
map.put("requestedPage", vreq.getRequestURL().toString());
|
map.put("requestedPage", vreq.getRequestURL().toString());
|
||||||
|
|
||||||
|
// In template: ${now?date}, ${now?datetime}, ${now?time}
|
||||||
|
map.put("now", new Date());
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,11 +40,6 @@ public class SamplesController extends FreemarkerHttpServlet {
|
||||||
// List<String> apples = null; // error
|
// List<String> apples = null; // error
|
||||||
body.put("apples", apples); // without this: 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}
|
|
||||||
|
|
||||||
// You can add to a collection AFTER putting it in the template data model.
|
// You can add to a collection AFTER putting it in the template data model.
|
||||||
// The data model contains a reference to the collection, not a copy.
|
// The data model contains a reference to the collection, not a copy.
|
||||||
List<String> fruit = new ArrayList<String>();
|
List<String> fruit = new ArrayList<String>();
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
<li>Current date: ${now?date}</li>
|
<li>Current date: ${now?date}</li>
|
||||||
<li>Current time: ${now?time}</li>
|
<li>Current time: ${now?time}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<h3>Dates</h3>
|
||||||
|
|
||||||
|
|
||||||
<h3>Formatted datetime</h3>
|
<h3>Formatted datetime</h3>
|
||||||
<p><p>${dt.xsdDateTimeToYear(xsddatetime)}</p>
|
<p><p>${dt.xsdDateTimeToYear(xsddatetime)}</p>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue