Results 1 to 2 of 2

Thread: Troubles with Velocity Toolbox

  1. #1
    Join Date
    Sep 2007
    Posts
    19

    Default Troubles with Velocity Toolbox

    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:

    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>
    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).

    Lastly, I've also tried putting the tool directly into the template context in my controller as
    Code:
    model.put("mathTool", new MathTool())
    but that doesn't work either.

    Thanks for any pointers!

  2. #2
    Join Date
    Feb 2011
    Posts
    2

    Default

    hi,i have the same problem with you,now do you resolve?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •