You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Bruyn Bill <Br...@mcao.maricopa.gov> on 2006/03/03 21:54:58 UTC

[FLOW] sendPageAndWait continuation storage

When a continuation is created by sendPageAndWait, where is it stored?
Can I access it with flowscript or in the sitemap?

I have a scenario similar to the 'flowscript continuation from external
reply' problem discussed recently.  What I'm trying to do is iterate
over a list, and for each item in it, call out to some remote process
that will render a 'PDF Form' with my continuation-id in its submit
button.  So something like the following:

//for each element in the list
for (var i=0; i<subjects.size(); i++) {

  //get some more input, if you want
  var subject = subjects.get(i);
  bindFormInput("subject", subject, {subject:subject});
  
  //format xml input via jx generator
  var dom = pipeline.processToDOM("4pointsresult.xml", {doc:doc,
subject:subject});
  
  //let some other pipeline do stuff and a sendPage (actually another
top-level flowscript function)
  cocoon.sendPageAndWait("forms-server.flow", {dom: dom});
  
  //and then move on to the next element
}

I guess I could stick a jx template in the middle, grab the
continuation-id from there, and then post a form to my flowscript, but I
don't see how I'd preserve my bizData (dom) across requests like that...
And if the continuation os available to the jx generator, shouldn't I be
able to get to it without going thru all that?


TIA,


Bill Bruyn



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [FLOW] sendPageAndWait continuation storage

Posted by Simone Gianni <s....@thebug.it>.
Hi Bruyn,
there is a continuation input module, that you can use inside the  
sitemap to pass any continuation information to any object (an xsl, a 
flow, a custom object of yours). For example, to pass the continuation 
id as a parameter to an XSLT you can simply write :

<map:transform src="my.xsl">
  <map:parameter name="contid" value="{flow-continuation:id}"/>
</map:transform>

The syntax of the input module is xpath based, so to obtain for example 
the id of the parent continuation you can use 
flow-continuation:parentContinuation/id . You can find the javadocs for 
the input module class here 
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/modules/input/FlowContinuationModule.html 
.

Regarding bizdata, they are live only within the request, so once you 
have serialized the page (or PDF or whatever else) they are lost, but 
all you need is still in the flow, so once you get back there using the 
continuation id ...

Hope this helps,
Simone

Bruyn Bill wrote:

>When a continuation is created by sendPageAndWait, where is it stored?
>Can I access it with flowscript or in the sitemap?
>
>I have a scenario similar to the 'flowscript continuation from external
>reply' problem discussed recently.  What I'm trying to do is iterate
>over a list, and for each item in it, call out to some remote process
>that will render a 'PDF Form' with my continuation-id in its submit
>button.  So something like the following:
>
>//for each element in the list
>for (var i=0; i<subjects.size(); i++) {
>
>  //get some more input, if you want
>  var subject = subjects.get(i);
>  bindFormInput("subject", subject, {subject:subject});
>  
>  //format xml input via jx generator
>  var dom = pipeline.processToDOM("4pointsresult.xml", {doc:doc,
>subject:subject});
>  
>  //let some other pipeline do stuff and a sendPage (actually another
>top-level flowscript function)
>  cocoon.sendPageAndWait("forms-server.flow", {dom: dom});
>  
>  //and then move on to the next element
>}
>
>I guess I could stick a jx template in the middle, grab the
>continuation-id from there, and then post a form to my flowscript, but I
>don't see how I'd preserve my bizData (dom) across requests like that...
>And if the continuation os available to the jx generator, shouldn't I be
>able to get to it without going thru all that?
>
>
>TIA,
>
>
>Bill Bruyn
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>  
>
-- 
Simone Gianni

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: [FLOW] sendPageAndWait continuation storage

Posted by Bruyn Bill <Br...@mcao.maricopa.gov>.
Mmmmmmno.  I don't think so, anyway...
 
//don't know what this would do except get me the continuation (which is not where I want it).
var kont = cocoon.sendPageAndWait( data );

//which I need for this method
var output = client.renderForm ( kont.id + ".kont" );

//but then what?  i still need to stream the result to the client, so
cocoon.sendPage("result.pdf", {pdf: output.getOutputContent()});

//and then when the 'pdf form' gets submitted, execution resumes after 'var kont='? - I don't want that.

I was experimenting with something similar previously, where I created a bookmark (cocoon.createWebContinuation), posted back to that, and tested for some arbitrary request parameter - seemed kinda clunky though, and I had problems re-rendering the pdf form when the back button was used.
 
What problem/s do you see with the approach I outlined here originally?  Seems clean enough to me (though I haven't gotten to try it yet)...
 
________________________________

From: Leszek Gawron [mailto:lgawron@mobilebox.pl]
Sent: Sat 3/4/2006 11:43 AM
To: users@cocoon.apache.org
Subject: Re: [FLOW] sendPageAndWait continuation storage



Bruyn Bill wrote:
> Actually, I started that way.  The problem I have is that theFunctionBehindFormsServerFlow needs the continuation id created by sendPageAndWait, before it sends the page.  So
> 
>
> function otherFunction( dom ) {
>         //var data = processMyDom( dom );
>         //cocoon.sendPageAndWait( data );
>        
>         //looks more like
>
>         var output = client.renderForm(
>              //a bunch of parameters +
>              continuationID + ".kont",
>          );
>        
>         //and then i serialize a byte array obtained from the response.       
>         cocoon.sendPage("result.pdf", {pdf: output.getOutputContent()});
> }


what about:

var kont = cocoon.sendPageAndWait( data );

var output = client.renderForm ( kont.id + ".kont" );

?

--
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




Re: [FLOW] sendPageAndWait continuation storage

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Bruyn Bill wrote:
> Actually, I started that way.  The problem I have is that theFunctionBehindFormsServerFlow needs the continuation id created by sendPageAndWait, before it sends the page.  So
>  
> 
> function otherFunction( dom ) {
>         //var data = processMyDom( dom );
>         //cocoon.sendPageAndWait( data );
>         
>         //looks more like
> 
>         var output = client.renderForm(
>              //a bunch of parameters +
>              continuationID + ".kont", 
>          );
>         
>         //and then i serialize a byte array obtained from the response.        
>         cocoon.sendPage("result.pdf", {pdf: output.getOutputContent()});
> }


what about:

var kont = cocoon.sendPageAndWait( data );

var output = client.renderForm ( kont.id + ".kont" );

?

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: [FLOW] sendPageAndWait continuation storage

Posted by Bruyn Bill <Br...@mcao.maricopa.gov>.
Actually, I started that way.  The problem I have is that theFunctionBehindFormsServerFlow needs the continuation id created by sendPageAndWait, before it sends the page.  So
 

function otherFunction( dom ) {
        //var data = processMyDom( dom );
        //cocoon.sendPageAndWait( data );
        
        //looks more like

        var output = client.renderForm(
             //a bunch of parameters +
             continuationID + ".kont", 
         );
        
        //and then i serialize a byte array obtained from the response.        
        cocoon.sendPage("result.pdf", {pdf: output.getOutputContent()});
}


 
________________________________

From: Leszek Gawron [mailto:lgawron@mobilebox.pl]
Sent: Sat 3/4/2006 8:07 AM
To: users@cocoon.apache.org
Subject: Re: [FLOW] sendPageAndWait continuation storage



Hello,

First of all you problem shouldn't be solved the way you're trying it to.

Bruyn Bill wrote:
> When a continuation is created by sendPageAndWait, where is it stored?
> Can I access it with flowscript or in the sitemap?
>
> I have a scenario similar to the 'flowscript continuation from external
> reply' problem discussed recently.  What I'm trying to do is iterate
> over a list, and for each item in it, call out to some remote process
> that will render a 'PDF Form' with my continuation-id in its submit
> button.  So something like the following:
>
> //for each element in the list
> for (var i=0; i<subjects.size(); i++) {
>
>   //get some more input, if you want
>   var subject = subjects.get(i);
>   bindFormInput("subject", subject, {subject:subject});
>  
>   //format xml input via jx generator
>   var dom = pipeline.processToDOM("4pointsresult.xml", {doc:doc,
> subject:subject});
>  
>   //let some other pipeline do stuff and a sendPage (actually another
> top-level flowscript function)
>   cocoon.sendPageAndWait("forms-server.flow", {dom: dom});

The solution is shockingly simple. Instead of
cocoon.sendPageAndWait("forms-server.flow", {dom: dom})
do

theFunctionBehindFormsServerFlow( dom );

which in turn will call sendPageAndWait.

so you have:

function entryPoint() {
        while( someCondition ) {
                var input = getMeSomeMoreInput();
                var dom = getMeMyDomData();
                otherFunction( dom );
        }
}

function otherFunction( dom ) {
        var data = processMyDom( dom );
        cocoon.sendPageAndWait( data );
}

>  
>   //and then move on to the next element
> }
>
> I guess I could stick a jx template in the middle, grab the
> continuation-id from there, and then post a form to my flowscript, but I
> don't see how I'd preserve my bizData (dom) across requests like that...
> And if the continuation os available to the jx generator, shouldn't I be
> able to get to it without going thru all that?
>
>
> TIA,
>
>
> Bill Bruyn
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


--
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




Re: [FLOW] sendPageAndWait continuation storage

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Hello,

First of all you problem shouldn't be solved the way you're trying it to.

Bruyn Bill wrote:
> When a continuation is created by sendPageAndWait, where is it stored?
> Can I access it with flowscript or in the sitemap?
> 
> I have a scenario similar to the 'flowscript continuation from external
> reply' problem discussed recently.  What I'm trying to do is iterate
> over a list, and for each item in it, call out to some remote process
> that will render a 'PDF Form' with my continuation-id in its submit
> button.  So something like the following:
> 
> //for each element in the list
> for (var i=0; i<subjects.size(); i++) {
> 
>   //get some more input, if you want
>   var subject = subjects.get(i);
>   bindFormInput("subject", subject, {subject:subject});
>   
>   //format xml input via jx generator
>   var dom = pipeline.processToDOM("4pointsresult.xml", {doc:doc,
> subject:subject});
>   
>   //let some other pipeline do stuff and a sendPage (actually another
> top-level flowscript function)
>   cocoon.sendPageAndWait("forms-server.flow", {dom: dom});

The solution is shockingly simple. Instead of 
cocoon.sendPageAndWait("forms-server.flow", {dom: dom})
do

theFunctionBehindFormsServerFlow( dom );

which in turn will call sendPageAndWait.

so you have:

function entryPoint() {
	while( someCondition ) {
		var input = getMeSomeMoreInput();
		var dom = getMeMyDomData();
		otherFunction( dom );
	}
}

function otherFunction( dom ) {
	var data = processMyDom( dom );
	cocoon.sendPageAndWait( data );
}

>   
>   //and then move on to the next element
> }
> 
> I guess I could stick a jx template in the middle, grab the
> continuation-id from there, and then post a form to my flowscript, but I
> don't see how I'd preserve my bizData (dom) across requests like that...
> And if the continuation os available to the jx generator, shouldn't I be
> able to get to it without going thru all that?
> 
> 
> TIA,
> 
> 
> Bill Bruyn
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org