com.niggle.templates.freemarkerimpl
Class LazyHashModel
java.lang.Object
|
+--com.niggle.templates.PresentationWrapper
|
+--com.niggle.templates.freemarkerimpl.FreemarkerPresentationWrapper
|
+--com.niggle.templates.freemarkerimpl.LazyHashModel
- All Implemented Interfaces:
- freemarker.template.TemplateHashModel, freemarker.template.TemplateModel, freemarker.template.TemplateModelRoot
- Direct Known Subclasses:
- RecordTemplate
- public class LazyHashModel
- extends FreemarkerPresentationWrapper
- implements freemarker.template.TemplateModelRoot
A freemarker template model implementation
that replaces freemarker.template.SimpleHash.
This class adds the following:
(i) using this, the page template syntax is case-insensitive
(meshes better with HTML, which is case-insensitive)
(ii) the data in a niggle record can be exposed to the page in one go.
(This is a big deal!)
(iii) the data model encapsulates an i18n locale.
(This is a very big deal. This will be the main point at which the canonical
storage strings in a data record get internationalized.)
(iv) You can expose a nested List or Map in one go via put
(v) This uses lazy evaluation, so should be significantly more efficient!
- Author:
- Jonathan Revusky
Method Summary |
void |
clearData()
Clears out the hash |
freemarker.template.TemplateModel |
get(java.lang.String key)
Overloaded so that the template variables
can be case-insensitive. |
boolean |
isEmpty()
|
void |
put(java.lang.String key,
boolean b)
Overloaded so that the template variables
can be case-insensitive. |
void |
put(java.lang.String key,
java.lang.Object val)
expose a List of niggle Records |
void |
put(java.lang.String key,
Record rec)
expose data from a record by key |
void |
put(java.lang.String key,
java.lang.String value)
Overloaded so that the template variables
can be case-insensitive. |
void |
put(java.lang.String key,
freemarker.template.TemplateModel tm)
Overloaded so that the template variables
can be case-insensitive. |
void |
remove(java.lang.String key)
Overloaded so that the template variables
can be case-insensitive. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LazyHashModel
public LazyHashModel()
LazyHashModel
public LazyHashModel(ServletInteraction interaction)
clearData
public void clearData()
- Clears out the hash
put
public void put(java.lang.String key,
freemarker.template.TemplateModel tm)
- Overloaded so that the template variables
can be case-insensitive.
- Specified by:
put
in interface freemarker.template.TemplateModelRoot
put
public void put(java.lang.String key,
java.lang.Object val)
- expose a List of niggle Records
- Parameters:
the
- variable name by which to expose the records.val
- the object to wrap as a freemarker template model.
expose on to a page: typically niggle records or scalars or lists
or nested hashes
put
public void put(java.lang.String key,
boolean b)
- Overloaded so that the template variables
can be case-insensitive.
put
public void put(java.lang.String key,
java.lang.String value)
- Overloaded so that the template variables
can be case-insensitive.
get
public freemarker.template.TemplateModel get(java.lang.String key)
throws freemarker.template.TemplateModelException
- Overloaded so that the template variables
can be case-insensitive.
- Specified by:
get
in interface freemarker.template.TemplateHashModel
remove
public void remove(java.lang.String key)
- Overloaded so that the template variables
can be case-insensitive.
- Specified by:
remove
in interface freemarker.template.TemplateModelRoot
put
public void put(java.lang.String key,
Record rec)
- expose data from a record by key
- Parameters:
key
- rec
- source of data.
isEmpty
public boolean isEmpty()
throws freemarker.template.TemplateModelException
- Specified by:
isEmpty
in interface freemarker.template.TemplateModel