net.sf.click.service
Interface TemplateService

All Known Implementing Classes:
VelocityTemplateService

public interface TemplateService

Provides a templating service interface.

Configuration

The default TemplateService is VelocityTemplateService.

However you can instruct Click to use a different implementation by adding the following element to your click.xml configuration file.

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <click-app charset="UTF-8">

     <pages package="net.sf.click.examples.page"/>

     <template-service classname="net.sf.click.extras.service.FreemarkerTemplateService">

 </click-app> 

Author:
Malcolm Edgar

Method Summary
 void onDestroy()
          Destroy the TemplateService.
 void onInit(ServletContext servletContext)
          Initialize the TemplateService with the given application configuration service instance.
 void renderTemplate(Page page, Map model, Writer writer)
          Render the given page to the writer.
 void renderTemplate(String templatePath, Map model, Writer writer)
          Render the given template and model to the writer.
 

Method Detail

onInit

public void onInit(ServletContext servletContext)
            throws Exception
Initialize the TemplateService with the given application configuration service instance.

This method is invoked after the TemplateService has been constructed.

Note you can access ConfigService by invoking ClickUtils.getConfigService(javax.servlet.ServletContext)

Parameters:
servletContext - the application servlet context
Throws:
Exception - if an error occurs initializing the Template Service

onDestroy

public void onDestroy()
Destroy the TemplateService.


renderTemplate

public void renderTemplate(Page page,
                           Map model,
                           Writer writer)
                    throws Exception
Render the given page to the writer.

Parameters:
page - the page template to render
model - the model to merge with the template and render
writer - the writer to send the merged template and model data to
Throws:
Exception - if an error occurs

renderTemplate

public void renderTemplate(String templatePath,
                           Map model,
                           Writer writer)
                    throws Exception
Render the given template and model to the writer.

Parameters:
templatePath - the path of the template to render
model - the model to merge with the template and render
writer - the writer to send the merged template and model data to
Throws:
Exception - if an error occurs