You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Tim Colson <tc...@cisco.com> on 2004/09/08 01:41:51 UTC

Using both Jar and Webapp resource paths

Nathan said:
> if there's ... no resource loader specified in the
> velocity.properties file, then the WebappLoader is used. 
> otherwise, if resource loader(s)
> is/are specified in whatever properties file the user tells 
> the VVS to use, the VVS will use that/those resource loader(s).

I'm trying to setup a dev environment where include paths can stay the same
for local files, as well as later when I bundle up the 'common'
layout/macros into a JAR. That jar will be shared among other projects. (Try
THAT, JSP! <grin>)

I have dual loaders working for VelocityViewServlet:

#---------------------------------------------------------------------------
-
# RESOURCE loaders
#---------------------------------------------------------------------------
-
resource.loader = class, webapp
#
# ClasspathResourceLoader
class.resource.loader.description = Velocity Classpath Resource Loader
class.resource.loader.class =
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
# WebappResourceLoader
webapp.resource.loader.description = Velocity Webapp Resource Loader
webapp.resource.loader.class=org.apache.velocity.tools.view.servlet.WebappLo
ader

To make paths work in either case, I added template directories into the
classpath. Works great to resolve "common/footer.vm" in
WEB-INF/templates/vm/common/footer.vm or inside a bundled common-ui.jar. I
looked at the WebappLoader and it seems the same functionality can be setup
in the config with webapp.resource.loader.path. 

Spiffy.  In fact, it works so well, I'm kind of spoiled now. <grin>

So just wanted to say my hats off to Geir/Nathan/Gabe/Marino and everyone
else for continuing to surprise me with code that Just Works. :-)

Cheers,
Timo











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