If you're using Spring then you could wire up the following (we have it wired into the applicationContext-service.xml file):
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"> <property name="velocityProperties"> <props> <prop key="resource.loader">class</prop> <prop key="class.resource.loader.class"> org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader </prop> <prop key="velocimacro.library"/> </props> </property> </bean> Although we're injecting it into services that generate email I would expect you can also inject the engine as a setter to an action. There are static methods available in VelocityEngineUtils that can be leveraged thereafter. - Andrew -----Original Message----- From: James Carr [mailto:james.r.c...@gmail.com] Sent: Thursday, January 08, 2009 8:51 AM To: struts-u...@apache.org Subject: [S2] Using an existing velocity template within struts2? Hi All, I have a small problem. I have an object that generates a velocity template that I want to use within a struts2 application that is using velocity... the method that produces the html is called from within the template. Anyhow, I cannot seem to make this work unless I call Velocity.init() explicitly within the action. Is there a better way? Thanks, James --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org