A simple way to test if the tool is in the context (and what it is) is
to see what output you get for:

$testingtool.class.name

also, if you check your logs, you should see whether or not the tool
(and toolbox for that matter) were loaded.

and remember, Velocity will only acknowledge public methods in public classes.

On 2/9/06, Christopher Townson <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I'm missing something really obvious here ...
>
> I'm just setting up a very simple velocity demo in Tomcat. I'm using
> VelocityViewServlet on its own - nothing else.
>
> in WEB-INF/web.xml I have:
> [excerpt]
> <servlet-name>velocity</servlet-name>
> <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</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>
> [/excerpt]
> (sevlet maps to *.html)
>
> In WEB-INF/classes I have a very simple TestingTool class that just has a few
> method returning various data types (String, int, and boolean)
>
> In WEB-INF/toolbox.xml I have:
> [excerpt]
> <tool>
>       <key>testingtool</key>
>       <scope>application</scope>
>       <class>com.nature.velocity.tools.util.TestingTool</class>
> </tool>
> [/excerpt]
>
> However, attempting to access properties or methods of the TestingTool class
> in templates with $testingtool.myMethod() fails (e.g. $testingtool.getCount()
> just prints "$testingtool.getCount()", presumably because nothing is present
> in the context)
>
> This is so simple - what am I missing? (It _is_ the getting towards the end of
> the afternoon here ;D)
>
> Thanks,
>
> Chris
>
> ********************************************************************************
> DISCLAIMER: This e-mail is confidential and should not be used by anyone who 
> is
> not the original intended recipient. If you have received this e-mail in error
> please inform the sender and delete it from your mailbox or any other storage
> mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
> liability for any statements made which are clearly the sender's own and not
> expressly made on behalf of Macmillan Publishers Limited or one of its agents.
> Please note that neither Macmillan Publishers Limited nor any of its agents
> accept any responsibility for viruses that may be contained in this e-mail or
> its attachments and it is your responsibility to scan the e-mail and
> attachments (if any). No contracts may be concluded on behalf of Macmillan
> Publishers Limited or its agents by means of e-mail communication. Macmillan
> Publishers Limited Registered in England and Wales with registered number 
> 785998
> Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS
> ********************************************************************************
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to