A comment has been created.

http://cocoon.zones.apache.org/daisy/documentation/1241.html

Document ID: 1241
Name: Tutorial: A Gentle Introduction to Cocoon Control Flow
Branch: main
Language: default

Created by: Patrick Heiden
Created on: 3/9/08 9:16:15 PM
Visibility: public

I actually don't know, if Babak is still within the game, but I guess, that 
following instructions should help to get the game running.

The first missing concept here is the so called 'sub-sitemap'. This is what you 
are told to create in a new subdirectory and fill it with the above 
sitemap-contents (e.g. the pipeline with id="flow-sample"). When talking about 
a sub-sitemap (a concept already established before cocoon 2.2), then you can 
think of a sub-application in order to structure your whole root-application. 
In my case I have created the above sub-sitemap inside a new created directory 
simply called 'new'. So far so good. What you now need to do is to tell your 
root-sitemap about that new sitemap. This is called 'mounting' the sub-sitemap 
and is actually done inside the root-sitemap (under 
myBlock1/src/main/resources/COB-INF). So open it and paste the following 
snipped:

<map:match pattern="games/**">
   <map:mount src="new/" uri-prefix="games"/>
</map:match>

What happens here is, that you have structured your applications main-block 
(which should be myBlock1 if you followed the tutorial mentioned on the top of 
this page) into several 'sitemaps'. Typically a main-block is responsible to 
act as main-controller of your application so you can say, that you created a 
sub-controller, too. In this case your root-sitemap would delegate each request 
like http://localhost:8888/myBlock1/games/FOO to the sub-sitemap. This comes 
from the defined pattern "games/**". Then the root-sitemap mounts your 
sub-sitemap, wich is inside the new-folder (see attribute src="new/"). One 
thing to talk about at this point is the last attribute: uri-prefix. What you 
actually want to achieve is, that only the part of your URI called FOO is 
delegated to your sub-sitemap and matched inside there. With the attribute 
uri-prefix you exactly do that, because the defined prefix is cut off and only 
FOO would be left. In our case we would call 
http://localhost/myBlock1/games/game and the only URI-part wich is getting 
inside your sub-sitemap for further processing will be "game". 

So by now you have created a sub-sitemap and connected it within your 
root-sitemap.

Some other little 'bugs' are left to be wiped-out. First of all the 
documents-directory needs to be created in subfolder (new), too. This is 
because your sub-sitemap expects them there following the given code! Same 
thing needs to be done for the flow-folder.
Directory structure would look like this:

new/
|-- documents
|    |-- guess.jx
|    `-- success.jx
|-- flow
|    `--game.js
`sitemap.xmap

And to solve Babaks problem, too, we also need to extend the sub-sitemaps code 
with the following snipped (paste this before your <map:pipeline>-definition):

<map:flow language="javascript">
   <map:script src="flow/game.js"/>
</map:flow>

This one is actually registers the games.js flowscript.

Thats it. mvn jetty:run and have fun guessing!