here's my code:

=================================================
1. flowscript ...
=================================================
function getWfMyOpenRequests() {
        //workflow-List of open Requests
        /*
        ...
        */
        showWfList(username,wfl,Packages.at.workflow.webdesk.wf.sharkimpl.SharkHandler.WF_LIST_TYPE_MY_OPEN_REQUESTS);
}

function showWfList(username,wfl,listtype){
        var numberOfWfItems=wfl.size();
        var maxWfItemsPerPage=glob_maxWfItemsPerPage;
        var maxPages=parseInt(numberOfWfItems/maxWfItemsPerPage);
       
        //continuation
        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="http://apache.org/cocoon/templates/jx/1.0">
  <config>
          <!--
        ....
        -->
          <continuationid>${bkm.id}</continuationid>
          <prevpage>${prevpage}</prevpage>
          <nextpage>${nextpage}</nextpage>
  </config>
  <jx:forEach var="wfitem" items="${wflist}">
  <!--
  ...
  -->
</wflist>
=================================================

=================================================
3. finally the xsl ...
=================================================
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:c-insert="http://apache.org/cocoon/insert"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1">

        <xsl:variable name="listtype">
                <xsl:value-of select="//config/listtype"/>
        </xsl:variable>
        <xsl:variable name="continuationid">
                <xsl:value-of select="//continuationid"/>
        </xsl:variable>
        <xsl:variable name="prevpage">
                <xsl:value-of select="//prevpage"/>
        </xsl:variable>
        <xsl:variable name="nextpage">
                <xsl:value-of select="//nextpage"/>
        </xsl:variable>
<!--
...
-->
        <xsl:template match="wflist">
                <!--
                ...
                -->
                                <xsl:element name="a">
                                        <xsl:attribute name="href">
                                                <xsl:value-of select="$continuationid"/>
                                                <xsl:text>.kont?showpage=</xsl:text>
                                                <xsl:value-of select="$prevpage"/>
                                        </xsl:attribute>
                                        <xsl:text>
                                                <img src="" style="border-width:0px;width:22px;height:22px">
                                        </xsl:text>
                                </xsl:element>
                <!--
                ...
                -->
        </xsl:template>
        <!--
        ...
        -->
</xsl:stylesheet>
=================================================

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
mailto:[EMAIL PROTECTED]
http://www.workflow.at



Roberto Pierpaoli <[EMAIL PROTECTED]>

09.06.2005 10:38

Please respond to
[email protected]

To
COCOON USERS MAILING LIST <[email protected]>
cc
Subject
Problems with the usage of bookmarks and continuations





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="">            <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="" 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="">  </map:generators>
 <map:transformers default="xslt"/>
 <map:serializers default="html"/>
 <map:matchers default="wildcard"/>
 <map:selectors default="browser">
   <map:selector name="exception"
src="">      <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=""> </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="">      <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="">      <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="">          <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]


Reply via email to