Skip to end of metadata
Go to start of metadata

As of SiteMesh 2.0.2 Velocity (.vm) decorators are supported.

Here is an example of how such a decorator (e.g. /decorators/main.vm) might look like:

Installation

Download Velocity 1.3.1 or higher and copy it into WEB-INF/lib. The SiteMesh distribution comes with velocity-dep-1.3.1.jar.

Download VelocityTools 2.0 and copy it into WEB-INF/lib. The SiteMesh distribution comes with velocity-tools-view-1.1.jar.

Download Commons Collections 2.1 or higher and copy it into WEB-INF/lib. The SiteMesh distribution comes with commons-collections.jar.

Add the following to WEB-INF/web.xml within the <web-app> tag:

Modify decorators.xml to reference a .vm decorator.

A working example is included with the SiteMesh source code distribution under the src/example-webapp directory.

Context

VelocityDecoratorServlet puts some things into the context object that you should be aware of:

$request (from VelocityViewServlet)

The HttpServletRequest object

$response (from VelocityViewServlet)

The HttpServletResponse object

$session (from VelocityViewServlet)

The HttpSession object

$application (from VelocityViewServlet)

The ServletContext object

$base

request.getContextPath()

$title

Parsed page title (<title>...<title>)

$head

Parsed page head

$body

Parsed page body

$page

SiteMesh's internal Page object

Anything else

Search for the attribute by that name in the request, session and application scopes

  • No labels