Here is an example of how such a decorator (e.g. /decorators/main.vm) might look like:
#parse ("/includes/decorators/header.vm") <h2>$title</h2> $head <img src="$base/images/logo.gif" border="0"> <td valign="top" class="body"> <div class="header"> <span class="pagetitle">$title</span> </div> $body </td> #parse ("/includes/decorators/footer.vm")
[web-app]/WEB-INF/lib
.
The SiteMesh distribution comes with velocity-dep-1.3.1.jar.[web-app]/WEB-INF/lib
.
The SiteMesh distribution comes with velocity-tools-view-1.1.jar.[web-app]/WEB-INF/lib
.
The SiteMesh distribution comes with commons-collections.jar.[web-app]/WEB-INF/web.xml
within the <web-app>
tag:<servlet> <servlet-name>sitemesh-velocity</servlet-name> <servlet-class>com.opensymphony.module.sitemesh.velocity.VelocityDecoratorServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>sitemesh-velocity</servlet-name> <url-pattern>*.vm</url-pattern> </servlet-mapping>
decorators.xml
to reference a .vm
decorator.A working example is included with the SiteMesh distribution, under the src/example-webapp directory.
$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 |