com.revusky.niggle.templates.freemarkerimpl
Class FreemarkerPage

java.lang.Object
  |
  +--com.revusky.niggle.templates.freemarkerimpl.FreemarkerPage
All Implemented Interfaces:
Page

public class FreemarkerPage
extends java.lang.Object
implements Page

An implementation of the com.revusky.niggle.templates.Page interface that uses the freemarker template library.

Author:
Jonathan Revusky

Field Summary
protected  LazyHash model
           
 
Constructor Summary
FreemarkerPage(freemarker.template.Template pageTemplate, LazyHash model, java.lang.ClassLoader classLoader, java.lang.String contentType)
          Creates a new FreemarkerPage.
 
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 exposeResourceBundle(java.lang.String lookupName)
          expose an instance of java.util.ResourceBundle as a template hash variable
protected  java.util.Locale getLocale()
           
 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
 

Field Detail

model

protected LazyHash model
Constructor Detail

FreemarkerPage

public FreemarkerPage(freemarker.template.Template pageTemplate,
                      LazyHash model,
                      java.lang.ClassLoader classLoader,
                      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. May NOT be null.
Method Detail

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 template
item - 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 template
b - sets to boolean value according to: b ? "true" : ""

exposeResourceBundle

public void exposeResourceBundle(java.lang.String lookupName)
Description copied from interface: Page
expose an instance of java.util.ResourceBundle as a template hash variable
Specified by:
exposeResourceBundle in interface Page

getLocale

protected java.util.Locale getLocale()