Details:
* Cocoon 2.1.7 standalone
* JDK 1.5.0_03
* Windows 2000 SP4
Is there a way to send to the browser the "id" of the continuation
created by the "sendPageAndWait" method?
I have realized a simple adder: the user is asked for an augend and he
can add (using the "add" button) any number of augends, when he presses
"stop" the total is shown.
I would like the application to go on normally if the inserted value is
a number, while, if the value is not a number, the application should
start over from the beginning.
I thought to send to the browser the right continuation "id" as a
parameter of the "sendPageAndWait" method: if the value is not a number
I send the "id" of a bookmark created at the beginning of the
application, if the value is a number I (would like to) send the "id" of
the continuation created by the "sendPageAndWait" method. In this way I
could use a single "form", assigning to the "action" attribute the value
passed by the "sendPageAndWait" method.
Is it possible?
Follows the code:
************** Flowscript *********************
function main() {
var askAugend = "Inserire un nuovo addendo"
var pl = cocoon.createPageLocal();
pl.augend = 0;
pl.iteration = 0;
var bkm = cocoon.createWebContinuation();
while (true) {
cocoon.sendPageAndWait("askForAugend.jx", {"askAugend" : askAugend,
"partial" : pl.augend, "iter" : pl.iteration,"bkm" : ???????????????????});
pl.iteration++;
var newAugend = parseFloat( cocoon.request.get("augend") );
var keepGoing = cocoon.request.get("keepGoing");
if (parseFloat(newAugend) && keepGoing) pl.augend += newAugend;
else if (!keepGoing) {
break;
}
else {
askAugend = "Input errato, ricomincia!";
cocoon.sendPageAndWait("askForAugend", {"bkm" : bkm, "askAugend"
: askaugend, "partial" : pl.augend, "iter" : pl.iteration});
}
}
cocoon.sendPage("total.jx", {"augend" : pl.augend} );
}
**************** askForAugend.jx and total.jx ***********************
<?xml version="1.0"?>
<html xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<head>
<title>cocoon simple adder</title>
</head>
<body>
<h1>The Mighty Adder</h1>
<h2>${askAugend}</h2>
<form method="post" action="${bkm}.kont">
<input type="text" name="augend"/>
<input type="submit" name="keepGoing" value="Add"/>
<input type="submit" name="getResult" value="Get the result"/>
</form>
<h3>Partial = ${partial}</h3>
<h4>Iteration = ${iter}</h4>
</body>
</html>
<?xml version="1.0"?>
<html xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<head>
<title>cocoon simple adder</title>
</head>
<body>
<h1>Here is the result: ${augend}</h1>
<p><a href="./">New adding</a></p>
</body>
</html>
*************** Sitemap *********************
<?xml version="1.0" encoding="UTF-8"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file">
<!-- in this example we use JXTemplateGenerator to insert
Flow variables in page content -->
<map:generator label="content,data" logger="sitemap.generator.jx"
name="jx"
src="org.apache.cocoon.generation.JXTemplateGenerator"/>
</map:generators>
<map:transformers default="xslt"/>
<map:serializers default="html"/>
<map:matchers default="wildcard"/>
<map:selectors default="browser">
<map:selector name="exception"
src="org.apache.cocoon.selection.XPathExceptionSelector">
<exception name="invalid-continuation"
class="org.apache.cocoon.components.flow.InvalidContinuationException"/>
<exception class="java.lang.Throwable" unroll="true"/>
</map:selector>
</map:selectors>
<map:actions/>
<map:pipes default="caching"/>
</map:components>
<map:views/>
<map:resources/>
<map:action-sets/>
<map:flow language="javascript">
<!-- Flow will use the javascript functions defined in game.js -->
<map:script src="flow/adder.js"/>
</map:flow>
<map:pipelines>
<map:component-configurations>
<global-variables/>
</map:component-configurations>
<map:pipeline>
<!-- no filename: call main() in game.js -->
<map:match pattern="">
<map:call function="main"/>
</map:match>
<!-- use JXtemplate to generate page content -->
<map:match pattern="*.jx">
<map:generate type="jx" src="documents/{1}.jx"/>
<map:serialize type="xhtml"/>
</map:match>
<!-- .kont URLs are generated by the Flow system for continuations -->
<map:match pattern="*.kont">
<map:call continuation="{1}"/>
</map:match>
<!-- handle invalid continuations -->
<!-- this style of handling invalidContinuation is now deprecated: -->
<!-- this URI will never be called automatically anymore. -->
<!-- see handle-errors below -->
<map:match pattern="invalidContinuation">
<map:generate src="documents/invalidContinuation.xml"/>
<map:serialize type="xml"/>
</map:match>
<!-- the new non-hardcoded way of handling invalidContinuation -->
<map:handle-errors>
<map:select type="exception">
<map:when test="invalid-continuation">
<map:generate src="documents/invalidContinuation.html"/>
<map:serialize type="xhtml"/>
</map:when>
</map:select>
</map:handle-errors>
</map:pipeline>
</map:pipelines>
</map:sitemap>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]