FreeMarker Template Engine

Document created by resplin Employee on Jun 6, 2015
Version 1Show Document
  • View in full screen mode

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



FreemarkerTemplate Engine
FreeMarker


Data Binding


FreeMarker provides simple data binding support, but it's still flexible.  Templates are bound to data via a tree data model.

The data model is built using Java as demonstrated here.  The demo simply constructs the tree using a combination of values and hash tables.  However, the data model itself is represented as a series of Java Interfaces, thus allowing any data backend.  In the demo, the values and hash tables are automatically adapted to support the Java Interfaces.  The interfaces are detailed here.

Basically, almost any data source can be bound, such as SQL ResultSet. Popular POJO binding is provided out-of-the-box.  But, advanced examples such as the XML Node binding as described here are also possible.

An interesting concept is the notion of a method.  This provides dynamic capability, and could possibly be used to extend the tree data model template rendering time.


Web Support


There's support for using FreeMarker in the web-tier as described here.  It's possible to use JSP tags in FreeMarker templates, and use FreeMarker templates in JSP, although how well this actually works has to be tested.


Alfresco Binding


Options...


  1. Create tree data model via custom code against our Java API (as per starter examples in FreeMarker)
  2. Develop custom TemplateInterface adaptors against Alfresco Node & QueryResult concepts
  3. Transform Alfresco model / resultset to XML
  4. Bind against Web-tier Repository POJO classes

Questions


  1. Template use-cases? Each use-case drives the data binding
    1. Alternative Web Client Views (e.g. property, space)
    2. Microsite for a project space
    3. WCM
  2. Should we investigate providing a JSP tag library for use in any JSP templating environment?

Attachments

    Outcomes