John Reynolds <[EMAIL PROTECTED]> wrote: > Hi Mike, thanks for the quick reply! > > Here is where i think all those beers from college are taking a toll =) > > ==> assumes your DateTool is named "date" <== > > Can in instantiate the tool from within the template? right now i am not > putting the tool into the velocity context in my action servlet.
You'll probably be better off keeping the discussion on the list. I've been known to give people mis-advice that has to be corrected by others :) No, you have to pre-add tools to the context. You can either do this in code (add it just like any other velocity context attribute -- nothing special about a tool, it's just a java object assigned to an attribute) or you can configure it via web.xml. You can probably also stick into a session/request/application level attribute if you had to, but that's out of my experience. If you're using web.xml, it'd be something like this: <!-- Define Velocity template compiler --> <servlet> <servlet-name>velocity</servlet-name> <servlet-class> org.apache.velocity.tools.view.servlet.VelocityLayoutServlet </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> <load-on-startup>10</load-on-startup> </servlet> Toolbox.xml looks something like this <?xml version="1.0"?> <toolbox> <tool> <key>date</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.DateTool</class> </tool> </toolbox> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]