On 2/19/06, David Sperling <[EMAIL PROTECTED]> wrote: > Hi- > > I'm trying to send mail from a Struts Action with velocity 1.5 and > velocity-tools-1.2. > > The faq: > http://wiki.apache.org/jakarta-velocity/VelocityFAQ > Says: > >>You can get this instance for other uses of velocity by calling > getVelocityEngine > >>from a subclass > > Another recommendation from this list was to: > >>To get the VelocityEngine from getVelocityEngine(), > > > So my question is how do you get the VelocityEngine from the > getVelocityEngine()? > > I've spent hours on google trying to find some code that calls the > getVelocityEngine() > but the only thing I could come up with was a VelocityManager class from > opensymphony. > And the VelocityManager.java class from opensymphony is quite complex > and has > many dependencies.
i'm not surprised you didn't find much on Google. most VelocityViewServlet subclasses are probably in proprietart subclasses. still, it would be pretty easy to make the VelocityEngine accessible to your Struts Actions. since your actions have access to the servlet context, you can do a simple subclass of the VelocityViewServlet that puts the already configured VelocityEngine into the ServletContext attributes. something like: public MyVVS extends VelocityViewServlet { public void init(ServletConfig config) throws ServletException { super.init(config); VelocityEngine engine = getVelocityEngine(); config.getServletContext().setAttribute("velocityEngine", engine); } } then you just pull the engine out of the servlet context in your Struts Action. :) > Cheers, > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]