You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "White, Joshua A (HTSC, CASD)" <Jo...@thehartford.com> on 2004/01/28 14:58:34 UTC

Templates not located in the root of classpath

All,
 
I would like to put my velocity templates in one of my package directories.
If I put the templates in my build directory, they get found.  If they are
paced in build/com/mydomain/templates/ they are not found.  Do I have to
reference it like a java class (com.mydomain.templates.mytemplate.vm)?
Could you offer some suggestions?
 
Thanks,
 
Joshua
 
 
 
 
 
 
This is how I initialize velocity and get a template:
 
    protected void configureVelocity(VelocityEngine engine)
        throws Exception {
        Properties props = new Properties();
        props.setProperty(VelocityEngine.RESOURCE_LOADER,"classpath");
        props.setProperty("classpath." + VelocityEngine.RESOURCE_LOADER +
".class", ClasspathResourceLoader.class.getName());
        engine.init(props);
    }
 
    protected Template getTemplate()
        throws Exception {
        Template template = velocityEngine.getTemplate("MyTemplate.vm");
        return template;
    }


This communication, including attachments, is for the exclusive use of 
addressee and may contain proprietary, confidential or privileged 
information. If you are not the intended recipient, any use, copying, 
disclosure, dissemination or distribution is strictly prohibited. If 
you are not the intended recipient, please notify the sender 
immediately by return email and delete this communication and destroy all copies.


Re: Templates not located in the root of classpath

Posted by "Manjush G. Menon" <ma...@lycos.co.uk>.
try adding the folder into your classpath
--

Manjush

----- Original Message -----
From: "White, Joshua A (HTSC, CASD)" <Jo...@thehartford.com>
To: <ve...@jakarta.apache.org>
Sent: Wednesday, January 28, 2004 7:28 PM
Subject: Templates not located in the root of classpath


> All,
>
> I would like to put my velocity templates in one of my package directories.
> If I put the templates in my build directory, they get found.  If they are
> paced in build/com/mydomain/templates/ they are not found.  Do I have to
> reference it like a java class (com.mydomain.templates.mytemplate.vm)?
> Could you offer some suggestions?
>
> Thanks,
>
> Joshua
>
>
>
>
>
>
> This is how I initialize velocity and get a template:
>
>     protected void configureVelocity(VelocityEngine engine)
>         throws Exception {
>         Properties props = new Properties();
>         props.setProperty(VelocityEngine.RESOURCE_LOADER,"classpath");
>         props.setProperty("classpath." + VelocityEngine.RESOURCE_LOADER +
> ".class", ClasspathResourceLoader.class.getName());
>         engine.init(props);
>     }
>
>     protected Template getTemplate()
>         throws Exception {
>         Template template = velocityEngine.getTemplate("MyTemplate.vm");
>         return template;
>     }
>
>
> This communication, including attachments, is for the exclusive use of
> addressee and may contain proprietary, confidential or privileged
> information. If you are not the intended recipient, any use, copying,
> disclosure, dissemination or distribution is strictly prohibited. If
> you are not the intended recipient, please notify the sender
> immediately by return email and delete this communication and destroy all
copies.
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org