org.apache.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="org.apache.click.examples.page"/>

     <template-service classname="org.apache.click.extras.service.FreemarkerTemplateService">

 </click-app> 


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<String,?> model, Writer writer)
          Render the given page to the writer.
 void renderTemplate(String templatePath, Map<String,?> model, Writer writer)
          Render the given template and model to the writer.
 

Method Detail

onInit

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

void onDestroy()
Destroy the TemplateService.


renderTemplate

void renderTemplate(Page page,
                    Map<String,?> model,
                    Writer writer)
                    throws IOException,
                           TemplateException
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:
IOException - if an IO error occurs
TemplateException - if template error occurs

renderTemplate

void renderTemplate(String templatePath,
                    Map<String,?> model,
                    Writer writer)
                    throws IOException,
                           TemplateException
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:
IOException - if an IO error occurs
TemplateException - if template error occurs