Let's look at the implementation of the view/allTasks application page, which lists all tasks provided by the DatabaseFacade.
The scenario is the following:
Here's the first pipeline definition in sitemap, activated by the view/allTasks request:
This causes the above request to call the query_allTasks() Flowscript function (Flowscript listing here).
Later, the Flowscript will call the internal/generate-view/taskList pipeline to generate a view using the JXTemplateGenerator and the views/taskListView.xml page:
The following lines of Flowscript code implement the first two steps of our scenario, getting a List of TaskBean objects from the DatabaseFacade and passing it to the taskList pipeline.
0006 // Access java "database" facade object
0007 var db = Packages.org.apache.cocoon.samples.tour.beans.DatabaseFacade.getInstance();
...
0010 function query_allTasks() {
0011 list = db.getTasks();
0013 cocoon.sendPage("internal/generate-view/taskList", {
0014 title : "List of tasks",
0015 task : list,
0016 db : db
0017 });
As the taskList pipeline uses a JXTemplate generator, the corresponding
page will have access to the variables passed with the sendPage call.
The db object is also passed to the page, but it is only used to access its db.version field.
We're not using continuations here (there's no sendPageAndWait), Flowscript serves only as a thin layer of glue between our Java objects and our JXTemplate view page.
Here's the JXtemplate page that generates the taskList view, using the title, task and db variables supplied by the above Flowscript code:
Note the use of a <c:forEach> element, from the JXTemplate namespace, to iterate over members of the task collection.
Let's summarize what happened here: