cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Malic <>
Subject Re: Problems with the usage of bookmarks and continuations
Date Thu, 09 Jun 2005 09:22:53 GMT
here's my code:

1. flowscript ...
function getWfMyOpenRequests() {
        //workflow-List of open Requests

function showWfList(username,wfl,listtype){
        var numberOfWfItems=wfl.size();
        var maxWfItemsPerPage=glob_maxWfItemsPerPage;
        var maxPages=parseInt(numberOfWfItems/maxWfItemsPerPage);
        var bkm = cocoon.createWebContinuation(); 
        //here code will continue
        //get the details of a subset of workflow-processes
        cocoon.sendPageAndWait("views/WfList", {
                wflist: wflist,
                listtype: listtype,
                bkm: bkm,
                prevpage: prevPage,
                nextpage: nextPage

2. jx-xml file ...
<?xml version="1.0"?>
<wflist xmlns:jx="">
  <jx:forEach var="wfitem" items="${wflist}">

3. finally the xsl ...
<xsl:stylesheet version="1.0" 

        <xsl:variable name="listtype">
                <xsl:value-of select="//config/listtype"/>
        <xsl:variable name="continuationid">
                <xsl:value-of select="//continuationid"/>
        <xsl:variable name="prevpage">
                <xsl:value-of select="//prevpage"/>
        <xsl:variable name="nextpage">
                <xsl:value-of select="//nextpage"/>
        <xsl:template match="wflist">
                                <xsl:element name="a">
                                        <xsl:attribute name="href">

hope this helps.

Mit freundlichen Grüßen / Best regards
Alexander Malic
Developer, Junior Consultant
workflow EDV-GmbH
A-1030 Wien, Dannebergplatz 6 / 23

mobile: +43  (0)676 844 96 82 21
phone:+43  (0)1  718 88 42 - 21
fax: +43 (0)1 718 88 42 - 30

Roberto Pierpaoli <> 
09.06.2005 10:38
Please respond to


Problems with the usage of bookmarks and continuations


   * 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" : 
    var newAugend = parseFloat( cocoon.request.get("augend") );
    var keepGoing = cocoon.request.get("keepGoing");
    if (parseFloat(newAugend) && keepGoing) pl.augend += newAugend;
    else if (!keepGoing) {
    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="">
  <title>cocoon simple adder</title>
  <h1>The Mighty Adder</h1>
        <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"/>
  <h3>Partial = ${partial}</h3>
  <h4>Iteration = ${iter}</h4>

<?xml version="1.0"?>
<html xmlns:jx="">
  <title>cocoon simple adder</title>
  <h1>Here is the result: ${augend}</h1>
  <p><a href="./">New adding</a></p>

*************** Sitemap *********************

<?xml version="1.0" encoding="UTF-8"?>
<map:sitemap xmlns:map="">

  <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"
  <map:transformers default="xslt"/>
  <map:serializers default="html"/>
  <map:matchers default="wildcard"/>
  <map:selectors default="browser">
    <map:selector name="exception" 
      <exception name="invalid-continuation"
      <exception class="java.lang.Throwable" unroll="true"/>
  <map:pipes default="caching"/>


<map:flow language="javascript">
  <!-- Flow will use the javascript functions defined in game.js -->
  <map:script src="flow/adder.js"/>


    <!-- no filename: call main() in game.js -->
    <map:match pattern="">
      <map:call function="main"/>

    <!-- use JXtemplate to generate page content -->
    <map:match pattern="*.jx">
      <map:generate type="jx" src="documents/{1}.jx"/>
      <map:serialize type="xhtml"/>

    <!-- .kont URLs are generated by the Flow system for continuations -->
    <map:match pattern="*.kont">
      <map:call continuation="{1}"/>

    <!-- 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"/>

    <!-- the new non-hardcoded way of handling invalidContinuation -->
      <map:select type="exception">
        <map:when test="invalid-continuation">
          <map:generate src="documents/invalidContinuation.html"/>
          <map:serialize type="xhtml"/>



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message