velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Concern regarding template path!
Date Sun, 13 Oct 2002 03:29:15 GMT
On 10/12/02 6:36 PM, "Raghushri Sankaran" <raghushri@netscape.net> wrote:

> When we tried to initialize the Velocity Engine, there was a run time
> exception saying that the velocity engine could not initialize because
> it was missing some files in the commons package and these are not
> included in the default jar file. I downloaded the RC1 version of 1.3.
> Is that the latest one? And if possible could you please provide a
> snippet of code illustrating how to initialize the velocity engine.

Yes - there are two jars in the distro, one is -dep.

That one contains all the dependencies needed. Otherwise, you need to get
logkit, oro, and collections, and they come in build/lib.

There are two ways to use the engine, one is the singleton, the other is the
standalone instance.

Singleton :

  // set your configuration properties here
  
  Velocity.init();


:)


Standalone>

  VelocityEngine ve = new VelocityEngine();

  // set your configuration properties here

  ve.init();


> 
> Geir Magnusson Jr. wrote:
> 
>> On 10/12/02 3:27 PM, "Raghushri Sankaran" <raghushri@netscape.net> wrote:
>> 
>>  
>> 
>>> Hi All,
>>>      I am just starting to use Velocity. I tried using the 1.3
>>> version but it gave me certain compilation problems when running the
>>> sample program provided in the manuals. I theninstalled the 1.1 version
>>> and everything worked fine. My only concern now is that I am trying to
>>> use it with ATG Dynamo application server. Id I just initialize velocity
>>> and merge the template , the template file is picked up from the app
>>> server home. This behaviour is expected, but when I try and give a
>>> relative path it does not work. Here is my code:
>>>    
>>> 
>> 
>> What was the problem with 1.3?  We don't want to support 1.1...
>> 
>>  
>> 
>>> try{
>>>    Properties p = new Properties();
>>>    p.setProperty("file.resource.loader.path","/templates");
>>>    Velocity.init(p);
>>>    VelocityContext vc = new VelocityContext();
>>>    vc.put("name","Superman");
>>>    StringWriter w = new StringWriter();
>>>    Velocity.mergeTemplate("t.vm",vc,w);
>>>    System.out.println("Template is :"+w);
>>>  }
>>>  catch(Exception e)
>>>  {
>>>    e.printStackTrace();
>>>  }
>>> 
>>> I get a ResourceNotFoundException even though my template t.vm is in
>>> <APPSERVERHOME>/templates directory. Can someone please help.
>>> 
>>> 
>>> --
>>> 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>
> 

-- 
Geir Magnusson Jr. 
geirm@adeptra.com                                    +1-203-355-2219 (w)
Adeptra Inc.                                         +1-203-247-1713 (m)



--
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