cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Oliver <>
Subject Flow/Velocity
Date Mon, 03 Mar 2003 00:11:44 GMT
I've just committed changes to support calling Velocity 
( from the Cocoon flow layer.

In order to not break any existing users of the VelocityGenerator, I've 
created a new generator:


This generator differs from the existing VelocityGenerator in the way it 
populates the context passed to the Velocity template. It provides two 

1) this - the bean object passed to sendPage*() in your script
2) continuation - the current continuation (an instance of 

In addition, the immediate properties of the bean object are also 
available in the context. So if your bean has a property "foo", you can 
access it in your template as $foo or as $

This means you can now write a flow script like this:

   function test() {
                    name: "Cocoon",
                    project: "Velocity",
                    when: new java.util.Date()

that calls a Velocity template like this:

   <?xml version="1.0"?>
     <para>This is my first Cocoon2 page!</para>
     <para>Hi!  This page is generated using $ from the 
$this.project project.</para>
     <para>Hi!  I can also access name, project, and when like this: 
This page is generated using $name from the $project project at 
$when.toString() .</para>

When the build for samples is fixed, I'll add a sample of using Velocity 
with flow scripts, but you should be able to try it yourself, so please 
do and let me know of any problems.



View raw message