public class VelocityTemplate extends AbstractTemplate
A Template implementation using the Apache Velocity templating engine. The engine itself is required as a separate module, VelocityEngineModule. The base functionality is defined in the AbstractTemplate base class and only the actual template processing is done here.
A few items are automatically added in the template context, in addition to the ones specified in initialisation parameters, as described in AbstractTemplate documentation. These are used to overcome some of the limitations in Velocity template language. The urlencoder parameter contains a URLEncoder object which can help with encoding values used in URLs. listmaker variable contains an InstanceMaker that can make ArrayLists, it is difficult to create new lists in Velocity without this. These helper classes are defined in org.wandora.modules.velocityhelpers along with other similar helpers, which you may want to add to the context manually.
| Modifier and Type | Field and Description |
|---|---|
protected VelocityEngineModule |
engineModule |
protected org.apache.velocity.Template |
vTemplate |
templateCaching, templateContext, templateEncoding, templateFile, templateKey, templateManager, templateMime, templateVersionautoStart, isInitialized, isRunning, logging, loggingModule, moduleManager| Constructor and Description |
|---|
VelocityTemplate() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Collection<Module> |
getDependencies(ModuleManager manager)
Returns all the modules this module depends on.
|
protected java.lang.String |
getFullTemplatePath() |
java.util.HashMap<java.lang.String,java.lang.Object> |
getTemplateContext()
Returns the default context for this template.
|
protected org.apache.velocity.app.VelocityEngine |
getVelocityEngine() |
void |
process(java.util.HashMap<java.lang.String,java.lang.Object> params,
java.io.OutputStream output)
Processes the template with the given context and writes the resulting
content in the output stream.
|
void |
start(ModuleManager manager)
Starts the module.
|
void |
stop(ModuleManager manager)
Stops the module.
|
getEncoding, getKey, getMimeType, getVersion, initisInitialized, isRunning, requireLogging, toStringprotected org.apache.velocity.Template vTemplate
protected VelocityEngineModule engineModule
protected org.apache.velocity.app.VelocityEngine getVelocityEngine()
protected java.lang.String getFullTemplatePath()
getFullTemplatePath in class AbstractTemplatepublic java.util.Collection<Module> getDependencies(ModuleManager manager) throws ModuleException
ModulegetDependencies in interface ModulegetDependencies in class AbstractTemplatemanager - The module manager handling this module.ModuleExceptionpublic void start(ModuleManager manager) throws ModuleException
Modulestart in interface Modulestart in class AbstractTemplatemanager - The module manager handling this module.ModuleExceptionpublic void stop(ModuleManager manager)
Modulestop in interface Modulestop in class AbstractTemplatemanager - The module manager handling this module.public java.util.HashMap<java.lang.String,java.lang.Object> getTemplateContext()
TemplategetTemplateContext in interface TemplategetTemplateContext in class AbstractTemplatepublic void process(java.util.HashMap<java.lang.String,java.lang.Object> params,
java.io.OutputStream output)
Templateprocess in interface Templateprocess in class AbstractTemplateparams - The template context used for processing of the template.output - The output stream where the result is written.Copyright 2004-2015 Wandora Team