Pages

Wednesday, April 09, 2008

Configure Velocity Macro with Struts2 and sitemesh

To define velocimacros in Struts2 using sitemesh, you would need to set init param to the sitemesh-velocity filter in web.xml

<servlet>
<servlet-name>sitemesh-velocity</servlet-name>
<servlet-class>com.opensymphony.module.sitemesh.velocity.VelocityDecoratorServlet</servlet-class>
<init-param>
<param-name>org.apache.velocity.toolbox</param-name>
<param-value>/WEB-INF/toolbox.xml</param-value>
</init-param>

<init-param>
<param-name>org.apache.velocity.properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
</init-param>
</servlet>

In velocity.properties you would need to declare whatever global velocity macro files like cited below.

# Velocity Macro libraries.
velocimacro.library = /WEB-INF/VM_global_library.vm

For more information on Velocimacro refer to http://velocity.apache.org/engine/devel/user-guide.html#velocimacros

0 comments:

Post a Comment