You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by da...@cocoon.zones.apache.org on 2005/10/14 15:20:35 UTC
[DAISY] Updated: Advanced Control Flow - Tutorial
A document has been updated:
http://cocoon.zones.apache.org/daisy/legacydocs/520.html
Document ID: 520
Branch: main
Language: default
Name: Advanced Control Flow - Tutorial (previously Advanced Control Flow)
Document Type: Document (unchanged)
Updated on: 10/14/05 1:20:28 PM
Updated by: Helma van der Linden
A new version has been created, state: publish
Parts
=====
Content
-------
This part has been updated.
Mime type: text/xml (unchanged)
File name: (unchanged)
Size: 11328 bytes (previous version: 11336 bytes)
Content diff:
(11 equal lines skipped)
<p>Create the following <tt>sitemap.xmap</tt> in the new subdirectory:</p>
--- <pre>
--- <?xml version="1.0" encoding="UTF-8"?>
+++ <pre><?xml version="1.0" encoding="UTF-8"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
(81 equal lines skipped)
the player. Create the file <tt>guess.jx</tt>, which will be the page the player
will enter their guess:</p>
--- <pre>
--- <?xml version="1.0"?>
+++ <pre><?xml version="1.0"?>
<html xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<head>
<title>cocoon flow number guessing game</title>
(13 equal lines skipped)
<p>You'll also need a page to display when the person chooses the correct
number. Name it <tt>success.jx</tt> (Again in <tt>documents/</tt>):</p>
--- <pre>
--- <?xml version="1.0"?>
+++ <pre><?xml version="1.0"?>
<html xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<head>
<title>cocoon flow number guessing game</title>
(18 equal lines skipped)
<p>Create the following file named <tt>game.js</tt>:</p>
--- <pre>
--- function main() {
+++ <pre>function main() {
var random = Math.round( Math.random() * 9 ) + 1;
(43 equal lines skipped)
<p>We now get to the following line, where things start to get interesting:</p>
--- <pre>
--- cocoon.sendPageAndWait("guess.jxt", { "random" : random, "hint" : hint, "guesses" : guesses} );
+++ <pre>cocoon.sendPageAndWait("guess.jxt", { "random" : random, "hint" : hint, "guesses" : guesses} );
</pre>
<p>The Flow layer sends the contents of the URI "guess.jx" which is matched in
(5 equal lines skipped)
<p>We could also do the following:</p>
--- <pre>
--- cocoon.sendPageAndWait("guess.jx", { "foo" : random } );
+++ <pre>cocoon.sendPageAndWait("guess.jx", { "foo" : random } );
</pre>
<p>In this case, the value of random would be able to be substituted in our
(16 equal lines skipped)
<p>One thing to note is in the form which is sent back to Cocoon when the player
submits the guess:</p>
--- <pre>
--- <form method="post" action="${cocoon.continuation.id}.kont">
+++ <pre><form method="post" action="${cocoon.continuation.id}.kont">
</pre>
<p>Here, ${cocoon.continuation.id} is resolved to a unique identifier which
(4 equal lines skipped)
contains the continuation ID, plus ".kont", which we end up matching in the
sitemap:</p>
--- <pre>
--- <map:match pattern="*.kont">
+++ <pre><map:match pattern="*.kont">
<map:call continuation="{1}"/>
</map:match>
</pre>
(45 equal lines skipped)
Fields
======
no changes
Links
=====
no changes
Custom Fields
=============
no changes
Collections
===========
no changes