|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.click.extras.service.FreemarkerTemplateService
Provides a Freemarker TemplateService class.
<?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>Please note that Click ships with a default error.htm that is tailored for Velocity. If you switch to Freemarker replace the default error.htm with the one shown below. To ensure Click uses your template instead of the default one, copy/paste the template below to the web application path /click/error.htm. Click won't override your custom template.
<html> <head> <title>Error Page</title> <style type='text/css'> body, table, td { font-family: arial, sans-serif; font-size: 12px; } td.header { color: white; background: navy; } .errorReport { display: none; } a { color: blue; } </style> <script type='text/javascript'> function displayError() { errorReport.style.display = 'block'; } </script> </head> <body> <h1>Error Page</h1> <#if errorReport??> The application encountered an unexpected error. <p/> To return to the application click <a href="${context}">here</a>. <p/> <#if mode != "production"> To view the error details click <a href="#" onclick="displayError();">here</a>. <p/> ${errorReport} <p/> </#if> </#if> </body> </html>
Field Summary | |
protected int |
cacheDuration
The production/profile mode cache duration in seconds. |
protected ConfigService |
configService
The application configuration service. |
protected freemarker.template.Configuration |
configuration
The Freemarker engine configuration. |
Constructor Summary | |
FreemarkerTemplateService()
|
Method Summary | |
int |
getCacheDuration()
Return the template cache duration in seconds to use when the application is in "productin" or "profile" mode. |
void |
onDestroy()
|
void |
onInit(ServletContext servletContext)
|
void |
renderTemplate(Page page,
Map model,
Writer writer)
|
void |
renderTemplate(String templatePath,
Map model,
Writer writer)
|
void |
setCacheDuration(int cacheDuration)
Return the template cache duration in seconds to use when the application is in "productin" or "profile" mode. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected freemarker.template.Configuration configuration
protected int cacheDuration
protected ConfigService configService
Constructor Detail |
public FreemarkerTemplateService()
Method Detail |
public void onInit(ServletContext servletContext) throws Exception
onInit
in interface TemplateService
servletContext
- the application servlet context
Exception
- if an error occurs initializing the Template ServiceTemplateService.onInit(javax.servlet.ServletContext)
public void onDestroy()
onDestroy
in interface TemplateService
TemplateService.onDestroy()
public void renderTemplate(Page page, Map model, Writer writer) throws Exception
renderTemplate
in interface TemplateService
page
- the page template to rendermodel
- the model to merge with the template and renderwriter
- the writer to send the merged template and model data to
Exception
- if an error occursTemplateService.renderTemplate(Page, Map, Writer)
public void renderTemplate(String templatePath, Map model, Writer writer) throws Exception
renderTemplate
in interface TemplateService
templatePath
- the path of the template to rendermodel
- the model to merge with the template and renderwriter
- the writer to send the merged template and model data to
Exception
- if an error occursTemplateService.renderTemplate(String, Map, Writer)
public int getCacheDuration()
public void setCacheDuration(int cacheDuration)
cacheDuration
- the template cache duration in seconds to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |