com.niggle.templates.freemarkerimpl
Class FreemarkerPage
java.lang.Object
|
+--com.niggle.templates.freemarkerimpl.FreemarkerPage
- All Implemented Interfaces:
- Page
- public class FreemarkerPage
- extends java.lang.Object
- implements Page
An implementation of the com.niggle.templates.Page interface
that uses the freemarker template library.
- Author:
- Jonathan Revusky
Method Summary |
void |
expose(java.lang.String key,
boolean b)
Convenience method really, since all Freemarker
scalar variables are strings. |
void |
expose(java.lang.String key,
java.lang.Object item)
expose internal data, publishing it to make it
available to a Freemarker Template. |
void |
outputPage(javax.servlet.http.HttpServletResponse response,
boolean isStatic)
Prepare the cooked HTML, filling in the parameters
with data values, and send it to the end user
via the servlet's response stream. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
model
protected LazyHashModel model
FreemarkerPage
public FreemarkerPage(freemarker.template.Template pageTemplate,
LazyHashModel model,
java.lang.String contentType)
throws java.io.IOException
- Creates a new FreemarkerPage.
- Parameters:
pageTemplate
- the template to use.model
- the model to use.type
- the type of data to output. See class OutputTypes
for a list of supported types. May NOT be null.
FreemarkerPage
public FreemarkerPage(freemarker.template.Template pageTemplate,
LazyHashModel model)
throws java.io.IOException
outputPage
public void outputPage(javax.servlet.http.HttpServletResponse response,
boolean isStatic)
throws java.io.IOException
- Prepare the cooked HTML, filling in the parameters
with data values, and send it to the end user
via the servlet's response stream.
- Specified by:
outputPage
in interface Page
- Parameters:
response
- handle to where the output should go.- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
- Returns:
- the processed HTML as a String
expose
public void expose(java.lang.String key,
java.lang.Object item)
- expose internal data, publishing it to make it
available to a Freemarker Template.
- Specified by:
expose
in interface Page
- Parameters:
key
- name of the field in the templateitem
- source of the data to populate the template
expose
public void expose(java.lang.String key,
boolean b)
- Convenience method really, since all Freemarker
scalar variables are strings. Exposes the boolean
value as "true" or "". (Note that the empty string
in freemarker is essentially false
- Specified by:
expose
in interface Page
- Parameters:
key
- name of the field in the templateb
- sets to boolean value according to: b ? "true" : ""