velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Carmody <rcarm...@igetsmart.com>
Subject RE: changing file.resource.loader.path after velocity init
Date Wed, 28 Nov 2001 19:37:19 GMT
Thanks for the help!  I was really hoping to have multiple paths instead of
re-initing velocity(lot of cached templates and all).  I think I might try
to add some code, so that it would support multiple paths.  It looks like
you were planning on doing that in the FileResourceLoader anyway from the
javadoc: "This is a simple template file loader. Currently it only supports
a single path to templates. That'll change once we decide how we want to do
configuration."

Thanks again for your help!

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Tuesday, November 27, 2001 5:18 PM
To: velocity-user@jakarta.apache.org
Subject: Re: changing file.resource.loader.path after velocity init


On 11/27/01 5:09 PM, "Ryan Carmody" <rcarmody@igetsmart.com> wrote:

> Is it possible to change Velocity's v1.1 file.resource.loader.path after
it
> has gone through init?  I've tried manually setting it on top of the
> "default" velocity.properties but it appears I can only get that to work
> once, when the first init happens.

No, it doesn't accept changes after init() is called.

You might use a VelocityEngine and when you need to change the configuation,
just make and init() a new one.

I assume that this doesn't happen very often?

> 
> /////////////////////////////////////////////////
> private Velocity vengine;
> private VelocityContext context;
> 
>   public test(String pathname,String filename)
>   {
>       vengine = new Velocity();
>       context = new VelocityContext();
>       
>       try{ 
>           vengine.setProperty("file.resource.loader.path",pathname);
>           vengine.init();
>           template = vengine.getTemplate(filename);
>       }catch(ResourceNotFoundException ex){ System.out.println("Cannot
> find template " + templateFile +":"+ex.getMessage());
>       }catch(ParseErrorException ex){System.out.println("Syntax error in
> template " + templateFile + ":" + ex.getMessage() );
>       }catch(Exception ex){System.out.println("Syntax error in template "
> + templateFile + ":" + ex.getMessage() );
>       }
>   }
> /////////////////////////////////////////////////
> 
> Thanks In Advance,
> Ryan
> 
> --
> To unsubscribe, e-mail:
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:velocity-user-help@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



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

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


Mime
View raw message