AW: [opencms-dev] On how to integrate OpenCMS and velocity:

Michael Emmerich Michael.Emmerich at framfab.de
Tue Apr 2 10:44:49 CEST 2002


Alex,

>> Sure, the ResourceLoader cannot be accessed directly from 
>> outside of Velocity. But you do not need that, and you do not 
>> need to inititalize it form within an OpenCms Launcher since 
>> the ResourceLoader is some kind of driver to access the 
>> normal filesystem or to hook into something else (like 
>> Werners OpenCMSResourceLoader accesses the OpenCms VFS). 
>
>Sorry, but this is wrong. Currently, you need to pass the CmsObject to
>the resource launcher. Otherwise the ResouceLoader can not access the
>VFS. Again, look at the code.

I have looked at the code - you can be sure about that - and the only place
where the ResourceLoader is accessed is the LC_Velocity_OpenCMS class where
you pass the CmsObject to it, OpenCMSResourceLoader.setCmsObject(cms). Since
I count the LC_Velocity_OpenCMS as the mediator between OpenCms and
Velocity, I said that you do not need to access the OpenCMSResourceLoader
from the outside. 


>> 1) Read the requested file header, its a Velocity recource, 
>> so use the Velocity Launcher
>> 2) Get an instance of the LC_Velocity_OpenCMS class
>> 3) call the parseTemplate method of the LC_Velocity_OpenCMS 
>> class and forward the requested URI, the current parameters 
>> and the current CmsObject to it (similar to Werners code, 
>> except the template name would be the URI)
>> 4) the parseTemplate method will update the CmsObject in the 
>> OpenCMSResourceLoader, load the requested template via the 
>> OpenCMSResourceLoader and parse it (see Werners code).
>> 5) fetch the created output and send it to the response stream.
>
>There's something missing here between 2) and 3). If I have the VTL
>resource and even an instance of the LC_Velocity_OpenCMS, I could start
>a VTL. But what for? Velocity requires a VTL _and_ a class belonging to
>this Template. This is not the LC_Velocity_OpenCMS class, since this
>just handles the synchronization issue right now. This "Velocity Servlet
>class" must be initialized and called before 3). 

I was a bit wondering about this as well, since you mentioned it in your
mail from Saturday evening and I did not find the connection to the
"Velocity Servlet class" in the the code example. 
So please tell me where this tell me if this "Velocity Servlet class" is
used in the code example. We have four elements, the LC_Velocity_OpenCMS
class, the OpenCMSResourceLoader, the Velocity sample template and the Cms
Template class. The only component that gets not totaly clear by the example
is the "Velocity" object in the LC_Velocity_OpenCMS class - is this the
"Velocity Servlet class" to be used?

Bye,
	Michael





More information about the opencms-dev mailing list