updated for 2.2.0

Apache Velocity#

ztemplates supports apache velocity as rendering engine. In fact the author favors it for its simplicity.

ZVelocityRenderer#

To use add the annotation @Renderer(ZVelocityRenderer.class) to your view pojo and create a file named the same as your render pojo but with ending '.vm' at the same location as the '.java'

Configuration#

Velocity is configured by adding the file /WEB-INF/velocity.properties to your webapp.

Here is a sample /WEB-INF/velocity.properties

directive.foreach.counter.initial.value=0
resource.loader = classpath,file
classpath.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
classpath.resource.loader.cache=true
file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
file.resource.loader.cache=true
file.resource.loader.path=templates
input.encoding=UTF-8

Caching#

To aid rapid development there is a switch to disable velocity caching from a webapp context (you wont need to change any deployed file).

For example in tomcat add the following to your context.xml:

<context>
...
   <Parameter name="ztemplates.velocity.nocache" value="true"/>
...
</context>

You will need this if you want to use a tool like JRebel and you don't want to disable caching in velocity.properties so it will not get accidentally deployed in production.

Neuen Anhang hinzuf�gen

Du bist nicht autorisiert, Anh�nge zu dieser Seite hochzuladen.
« Diese Seite (Version-) wurde zuletzt am 29-Dez-2011 11:26 von gerdziegler.de ge�ndert.