I can't seem to get Velocity Toolbox set up correctly. I'm using VelocityLayoutViewResolver with VelocityLayoutView as my viewClass (which extends VelocityToolboxView).
I am successfully using the date, number, and formatter basic tools without issue and now I'd like to use the math tool to round some numbers in a template.
I've created a toolbox.xml file and set the toolboxConfigLocation attribute. This appears to get loaded correctly by the ToolboxManager, but the "key" name from the toolbox.xml is not available in my Velocity Context. How do I access the tools defined in toolbox.xml in my templates?
I've also tried making a separate bean for VelocityLayoutView and setting the toolAttributes property (inherited from VelocityView). This property is then parsed during renderMergedTemplateModel and would place the tool(s) in the context:
and then setting the viewClass attribute of VelocityLayoutViewResolver as a reference to that bean. However, I can't get that to initialize... eventually dying in org.apache.velocity.app.VelocityEngine due to a Null reference (this is probably a red herring).Code:<bean id="viewClass" class="org.springframework.web.servlet.view.velocity.VelocityLayoutView"> <property name="toolAttributes"> <props> <prop key="math">org.apache.velocity.tools.generic.MathTool</prop> </props> </property> <bean>
Lastly, I've also tried putting the tool directly into the template context in my controller asbut that doesn't work either.Code:model.put("mathTool", new MathTool())
Thanks for any pointers!


Reply With Quote