velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <>
Subject Re: How can a list of available templates be obtained?
Date Thu, 28 Mar 2002 13:57:50 GMT
On 3/28/02 2:13 AM, "Ben Peter" <> wrote:

> All,
> is there a way of obtaining a list of templates that a loader can provide?

Not really.  The problem is that a loader generally has a large space from
which it can load.  For example, the FileResourceLoader can access anything
below any of it's path nodes.  In practice, this is generally small, because
people usually configure with some limited directory like a /templates
directory in their webapp tree, but that too can contain multiple

Of course, you can configure "/" or "C:\" as your template path - so the
list could get quite big.

> I need to make a list of templates in a package/directory available in a drop
> down box, as they are page asset templates.
> With the FileResoureceLoader, this is not a problem, as I can use the same
> directory and read from that. However, I would like to deploy the templates in
> a jar file and use the ClasspathResourceLoader.

This gets even worse - because the ClasspathResourceLoader can access a
whole lot more than your template jar.
> Is there a way of finding all templates that reside, say, in
> /com/mycompany/app/templates ?

The JarResourceLoader might be one step forward for you - but I think that
too won't really do it, as there is no 'getAllTemplateNames()' type of
functionality anywhere in the API.

What you might do is extend the JarResourceLoader and use the Application
Attributes (see dev guide) feature to allow your app level code to talk to
the loader.  Then your loader can do fancy things for you and make them
available to the app.

Geir Magnusson Jr.                           
System and Software Consulting
The obvious solutions are challenging

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message