Velocity
Velocity is a Java-based template framework which provides the HTML rending engine
for Click. Velocity is very easy to learn, simple to use, and is also very capable.
Velocity is an open source
Jakarta Apache project licensed using
the Apache Software License.
Velocity's comprehensive online documentation is included in this distribution.
Object References
With Click you add objects to your page template using the Page's model. You can then access these objects
using Velocities $ reference notation. By default the ClickServlet adds the
following objects to page templates:
In your page templates you can access object references using a dot path notation. For example:
Welcome: $session.user.fullName
Or by using a more explicit Java notation:
Welcome: $session.get("user").getFullName()
Directives
In Velocity directives are prefixed by a # symbol. While
references access stuff, directives do stuff. The full set of Velocity directives are:
- #if #elseif #else -
output conditional on truth of statements.
- #foreach -
loops through a list of objects.
- #macro -
allows users to define a Velocimacro (VM), a repeated segment of a VTL template, as required.
- #set -
establishes the value of a reference.
- #include -
renders local file(s) that are not parsed by Velocity.
- #parse -
renders a local template that is parsed by Velocity.
- #stop -
stops the template engine.