You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Leszek Gawron <lg...@mobilebox.pl> on 2004/04/01 15:30:47 UTC

Call continuations from flow instead of sitemap

I have this snipped in one of my .js files :

var user = null;
function main( action ) {
	cocoon.response.setHeader( "Expires", "-1" );
	cocoon.response.setHeader( "Cache-Control", "no-cache" );
	cocoon.response.setHeader( "Pragma", "no-cache" );
	
	if ( user == null ) {
		loginInternal();
	}

	invoke( action );
}

This is based on the linotype sample. I add some headers to every flow
invocation response to make the IE not cache the content. It works fine but I
have a problem with continuations. This url:

http://ouzo/nTer/310b3f485d5a0c0a243e3011632a138d38357c38.continue

is still cached. So I need to set cache control headers for these urls too. 
I know I can make it in sitemap (via actions) but I would like to have ALL
logic in my flow and use sitemap.xmap only for view rendering. 

How can I achieve something like this (pseudo-code of course):

var user = null;
function main( action ) {
	cocoon.response.setHeader( "Expires", "-1" );
	cocoon.response.setHeader( "Cache-Control", "no-cache" );
	cocoon.response.setHeader( "Pragma", "no-cache" );
	
	if ( user == null ) {
		loginInternal();
	}

	if ( isFunction( action ) )
		invoke( action );
	else if ( isContinuation( action ) )
		runContinuation( action );
}

function isFunction( action ) {
	return ( this[ action ] != undefined );
}

function isContinuation( action ) {
	return endsWith( action, ".continue" );
}

function runContinuation( action ) {
	// ????????????
}

	lg

-- 
	Leszek Gawron


Re: Call continuations from flow instead of sitemap

Posted by Denis <de...@aic-info.com>.
ok ... sorry for the noise :-/

Denis


> On Fri, Apr 02, 2004 at 11:02:12AM +0200, Denis wrote:
> > Hi leszek,
> >
> > Could it be your loginValidator that in fact generates the NPE?
> >
> > //function header
> > function loginValidator( form )
> >
> > and at line 62 you wrote
> >  form.validator = loginValidator;
> > try:
> >   form.validator = loginValidator(form);
> This is not a function call it is a function "pointer". It works no
problem
> when I use standard <map:call continuation="{1}"/> instead of trying to
invoke
> it from flow. See the "Custom Validator Sample" in form samples. I use a
lot
> of function pointers in flow, to get the inverse of control pattern
running.
>
> lg
> -- 
>             __
>          | /  \ |        Leszek Gawron            //  \\
>         \_\\  //_/       ouzo@wlkp.org           _\\()//_
>          .'/()\'.     Phone: +48(501)720812     / //  \\ \
>           \\  //  recursive: adj; see recursive  | \__/ |
>


Re: Call continuations from flow instead of sitemap

Posted by Leszek Gawron <ou...@wlkp.org>.
On Fri, Apr 02, 2004 at 11:02:12AM +0200, Denis wrote:
> Hi leszek,
> 
> Could it be your loginValidator that in fact generates the NPE?
> 
> //function header
> function loginValidator( form )
> 
> and at line 62 you wrote
>  form.validator = loginValidator;
> try:
>   form.validator = loginValidator(form);
This is not a function call it is a function "pointer". It works no problem
when I use standard <map:call continuation="{1}"/> instead of trying to invoke
it from flow. See the "Custom Validator Sample" in form samples. I use a lot
of function pointers in flow, to get the inverse of control pattern running.

	lg
-- 
            __
         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/       ouzo@wlkp.org           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |


Re: Call continuations from flow instead of sitemap

Posted by Denis <de...@aic-info.com>.
Hi leszek,

Could it be your loginValidator that in fact generates the NPE?

//function header
function loginValidator( form )

and at line 62 you wrote
 form.validator = loginValidator;
try:
  form.validator = loginValidator(form);
instead ...

Hope this help,

Regards,

Denis


> On Thu, Apr 01, 2004 at 02:39:05PM -0500, Vadim Gritsenko wrote:
> > Leszek Gawron wrote:
> >
> > >I have this snipped in one of my .js files :
> > >
> > >
> > ...
> >
> > >function runContinuation( action ) {
> > >
> > >
> >
> > Provided that "action" contains continuation ID and not actual
> > continuation object... you need to lookupWebContinuation from the
> > ContinuationsManager component, this will give you WebContinuation
> > object. Once you have it... Something like this should be able to invoke
it:
> >
> >    var wk = contManager.lookupWebContinuation(action);
> >    var c = wk.getContinuation();
> >    c(c);
> Vadim,
> This does not work. I get this exception:
>
> rg.apache.avalon.framework.CascadingRuntimeException:
"resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 106:
uncaught JavaScript exception: at main
(file:/C:/dev/eclipse-workspace/nTer/build/webapp/nTer/flow/test.js, Line
12) at (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line
106): java.lang.NullPointerException
>
> org.apache.avalon.framework.CascadingRuntimeException:
"resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 106:
uncaught JavaScript exception:
> at main
(file:/C:/dev/eclipse-workspace/nTer/build/webapp/nTer/flow/test.js, Line
12)
> at  (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line
106):
> java.lang.NullPointerException
> at
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.c
allFunction(FOM_JavaScriptInterpreter.java:695)
> at
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(C
allFunctionNode.java:130)
> at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:49)
> at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invok
e(PreparableMatchNode.java:130)
> at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:72)
> at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(Pipel
ineNode.java:126)
> at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:72)
> at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(Pipe
linesNode.java:101)
> at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcess
or.java:336)
> at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcess
or.java:277)
> at
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNod
e.java:103)
> at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:49)
> at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invok
e(PreparableMatchNode.java:130)
> at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:72)
> at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(Pipel
ineNode.java:126)
> at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:72)
> at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(Pipe
linesNode.java:101)
> at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcess
or.java:336)
> at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcess
or.java:277)
> at org.apache.cocoon.Cocoon.process(Cocoon.java:619)
> at
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1074)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
> at
org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicatio
nHandler.java:342)
> at
com.mobilebox.hibernate.PersistenceManager.doFilter(PersistenceManager.java:
65)
> at
org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicatio
nHandler.java:334)
> at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandl
er.java:286)
> at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
> at org.mortbay.http.HttpContext.handle(HttpContext.java:1808)
> at
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext
.java:525)
> at org.mortbay.http.HttpContext.handle(HttpContext.java:1758)
> at org.mortbay.http.HttpServer.service(HttpServer.java:879)
> at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
> at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
> at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
> at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197)
> at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
> at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:496)
> Caused by: java.lang.NullPointerException
> at
org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon.jsGet_request(FO
M_Cocoon.java:1350)
> at
org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon.getRequest(FOM_C
ocoon.java:1404)
> at
org.apache.cocoon.forms.flow.javascript.FormsFlowHelper.getFormContext(Forms
FlowHelper.java:37)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
> at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:230)
> at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
> at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(Conti
nuationInterpreter.java:1134)
> at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(Conti
nuationInterpreter.java:190)
> at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(Conti
nuationInterpreter.java:138)
> at
org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(Interprete
dFunctionImpl.java:121)
> at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
> at
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.c
allFunction(FOM_JavaScriptInterpreter.java:686)
> ... 37 more
>
> I have attached the source of test.js
>
> When I disable the call to loginInternal, main application view is being
> shown. But after I press an action button there is an error with page
local
> variable. So it looks like invoking continuation this way does not set the
run
> environment properly
>
> lg
> -- 
>             __
>          | /  \ |        Leszek Gawron            //  \\
>         \_\\  //_/       ouzo@wlkp.org           _\\()//_
>          .'/()\'.     Phone: +48(501)720812     / //  \\ \
>           \\  //  recursive: adj; see recursive  | \__/ |
>
>


Re: Call continuations from flow instead of sitemap

Posted by Leszek Gawron <ou...@wlkp.org>.
On Thu, Apr 01, 2004 at 02:39:05PM -0500, Vadim Gritsenko wrote:
> Leszek Gawron wrote:
> 
> >I have this snipped in one of my .js files :
> > 
> >
> ...
> 
> >function runContinuation( action ) {
> > 
> >
> 
> Provided that "action" contains continuation ID and not actual 
> continuation object... you need to lookupWebContinuation from the 
> ContinuationsManager component, this will give you WebContinuation 
> object. Once you have it... Something like this should be able to invoke it:
> 
>    var wk = contManager.lookupWebContinuation(action);
>    var c = wk.getContinuation();
>    c(c);
Vadim,
This does not work. I get this exception:

rg.apache.avalon.framework.CascadingRuntimeException: "resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 106: uncaught JavaScript exception: at main (file:/C:/dev/eclipse-workspace/nTer/build/webapp/nTer/flow/test.js, Line 12) at (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line 106): java.lang.NullPointerException

org.apache.avalon.framework.CascadingRuntimeException: "resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 106: uncaught JavaScript exception: 
at main (file:/C:/dev/eclipse-workspace/nTer/build/webapp/nTer/flow/test.js, Line 12)
at  (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line 106):
java.lang.NullPointerException
	at org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.callFunction(FOM_JavaScriptInterpreter.java:695)
	at org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:130)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49)
	at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277)
	at org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:103)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:49)
	at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:126)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:72)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:101)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:336)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:277)
	at org.apache.cocoon.Cocoon.process(Cocoon.java:619)
	at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1074)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
	at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:342)
	at com.mobilebox.hibernate.PersistenceManager.doFilter(PersistenceManager.java:65)
	at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334)
	at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:286)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1808)
	at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:525)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1758)
	at org.mortbay.http.HttpServer.service(HttpServer.java:879)
	at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
	at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
	at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
	at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197)
	at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
	at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:496)
Caused by: java.lang.NullPointerException
	at org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon.jsGet_request(FOM_Cocoon.java:1350)
	at org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon.getRequest(FOM_Cocoon.java:1404)
	at org.apache.cocoon.forms.flow.javascript.FormsFlowHelper.getFormContext(FormsFlowHelper.java:37)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:230)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:1134)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:190)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:138)
	at org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(InterpretedFunctionImpl.java:121)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.callFunction(FOM_JavaScriptInterpreter.java:686)
	... 37 more

I have attached the source of test.js

When I disable the call to loginInternal, main application view is being
shown. But after I press an action button there is an error with page local
variable. So it looks like invoking continuation this way does not set the run
environment properly

	lg
-- 
            __
         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/       ouzo@wlkp.org           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |


Re: Call continuations from flow instead of sitemap

Posted by Reinhard Pötz <re...@apache.org>.
Leszek Gawron wrote:

>On Sat, Apr 03, 2004 at 01:58:51PM -0800, Christopher Oliver wrote:
>  
>
>>These ContinuationsManager API should _not_ be used in a flowscript. Use 
>>the sitemap to invoke your continuation, please.
>>
>>Is it possible to solve your problem by using a helper function to send 
>>the page:
>>
>>function sendPageAndWait(uri, biz, ttl) {
>> cocoon.response.setHeader( "Expires", "-1" );
>> cocoon.response.setHeader( "Cache-Control", "no-cache" );
>> cocoon.response.setHeader( "Pragma", "no-cache" );
>> return cocoon.sendPageAndWait(uri, biz, ttl);
>>}
>>    
>>
>This would not work as form.showForm() woudn't use this function ... 
>
>Intercepted flow is nicer idea though. Why is it still considered alpha?
>
>	lg
>  
>
Intercpeted flow needs some more development. Currently it is a proof of 
concept but not more. Don't know when I find more time to finish it.

-- 
Reinhard


Re: Call continuations from flow instead of sitemap

Posted by Christopher Oliver <re...@verizon.net>.
Leszek Gawron wrote:

>On Sat, Apr 03, 2004 at 01:58:51PM -0800, Christopher Oliver wrote:
>  
>
>>These ContinuationsManager API should _not_ be used in a flowscript. Use 
>>the sitemap to invoke your continuation, please.
>>
>>Is it possible to solve your problem by using a helper function to send 
>>the page:
>>
>>function sendPageAndWait(uri, biz, ttl) {
>> cocoon.response.setHeader( "Expires", "-1" );
>> cocoon.response.setHeader( "Cache-Control", "no-cache" );
>> cocoon.response.setHeader( "Pragma", "no-cache" );
>> return cocoon.sendPageAndWait(uri, biz, ttl);
>>}
>>    
>>
>This would not work as form.showForm() woudn't use this function ... 
>
>Intercepted flow is nicer idea though. Why is it still considered alpha?
>
>	lg
>  
>
If you were to use the V2 version of the CForms flowscript API you could 
do something like this:

function showForm(form, uri) {
    form.setBookmark();
    cocoon.response.setHeader( "Expires", "-1" );
    cocoon.response.setHeader( "Cache-Control", "no-cache" );
    cocoon.response.setHeader( "Pragma", "no-cache" );
    form.showForm(uri);
}

Whenever the form is redisplayed your script will resume right after the 
call to setBookmark(). You can insert additional code after that which 
will be executed each time before the form is sent to the browser.

Chris

Re: Call continuations from flow instead of sitemap

Posted by Leszek Gawron <ou...@wlkp.org>.
On Sat, Apr 03, 2004 at 01:58:51PM -0800, Christopher Oliver wrote:
> These ContinuationsManager API should _not_ be used in a flowscript. Use 
> the sitemap to invoke your continuation, please.
> 
> Is it possible to solve your problem by using a helper function to send 
> the page:
> 
> function sendPageAndWait(uri, biz, ttl) {
>  cocoon.response.setHeader( "Expires", "-1" );
>  cocoon.response.setHeader( "Cache-Control", "no-cache" );
>  cocoon.response.setHeader( "Pragma", "no-cache" );
>  return cocoon.sendPageAndWait(uri, biz, ttl);
> }
This would not work as form.showForm() woudn't use this function ... 

Intercepted flow is nicer idea though. Why is it still considered alpha?

	lg
-- 
            __
         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/       ouzo@wlkp.org           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |


Re: Call continuations from flow instead of sitemap

Posted by Tony Collen <co...@umn.edu>.
Christopher Oliver wrote:

> Uh, thanks. But Leszek is talking about the JS function 
> handleContinuation() defined in fom_system.js - not the Java method that 
> you point out. That method is not accessible to flowscripts.

Ahh, ok, I understand now.

Regards,

Tony


Re: Call continuations from flow instead of sitemap

Posted by Christopher Oliver <re...@verizon.net>.
Uh, thanks. But Leszek is talking about the JS function 
handleContinuation() defined in fom_system.js - not the Java method that 
you point out. That method is not accessible to flowscripts.

Chris

Tony Collen wrote:

> Tony Collen wrote:
>
>> Christopher Oliver wrote:
>>
>>> Leszek Gawron wrote:
>>
>>
>>
>>>> cocoon.handleContinuation( wk.getContinuation() );
>>>>     lg
>>>>  
>>>>
>>> Uh, it doesn't actually work properly in general, as you noticed 
>>> (with page locals). Also Cocoon.handleContinuation() is an internal 
>>> function that shouldn't be called except by Cocoon itself. You're 
>>> also not passing correct arguments to it.
>>
>>
>>
>> Hmmm:
>>
>> public void handleContinuation(String kontId, Scriptable parameters)
>>
>> If we only want it to be callable by Cocoon itself, why is it public? 
>> Does it need to be public for the Javascript stuff?
>
>
> Likewise, I would also argue the comments associated with 
> handleContinuation() suggest that you should be allowed to call it 
> from your Flowscript:
>
>     /**
>      * Perform the behavior of <map:call continuation="blah">
>      * This can be used in cases where the continuation id is not encoded
>      * in the request in a form convenient to access in the sitemap.
>      * Your script can extract the id from the request and then call
>                                                        ^^^^^^^^^^^^^
>      * this method to process it as normal.
>        ^^^^^^^^^^^
>
>      * @param kontId The continuation id
>      * @param parameters Any parameters you want to pass to the 
> continuation (may be null)
>      */
>
>
> Regards,
>
> Tony
>
>


Re: Call continuations from flow instead of sitemap

Posted by Tony Collen <co...@umn.edu>.
Tony Collen wrote:

> Christopher Oliver wrote:
> 
>> Leszek Gawron wrote:
> 
> 
>>> cocoon.handleContinuation( wk.getContinuation() );
>>>     lg
>>>  
>>>
>> Uh, it doesn't actually work properly in general, as you noticed (with 
>> page locals). Also Cocoon.handleContinuation() is an internal function 
>> that shouldn't be called except by Cocoon itself. You're also not 
>> passing correct arguments to it.
> 
> 
> Hmmm:
> 
> public void handleContinuation(String kontId, Scriptable parameters)
> 
> If we only want it to be callable by Cocoon itself, why is it public? 
> Does it need to be public for the Javascript stuff?

Likewise, I would also argue the comments associated with 
handleContinuation() suggest that you should be allowed to call it from 
your Flowscript:

     /**
      * Perform the behavior of <map:call continuation="blah">
      * This can be used in cases where the continuation id is not encoded
      * in the request in a form convenient to access in the sitemap.
      * Your script can extract the id from the request and then call
                                                        ^^^^^^^^^^^^^
      * this method to process it as normal.
        ^^^^^^^^^^^

      * @param kontId The continuation id
      * @param parameters Any parameters you want to pass to the 
continuation (may be null)
      */


Regards,

Tony


Re: Call continuations from flow instead of sitemap

Posted by Tony Collen <co...@umn.edu>.
Christopher Oliver wrote:
> Leszek Gawron wrote:

>> cocoon.handleContinuation( wk.getContinuation() );
>>     lg
>>  
>>
> Uh, it doesn't actually work properly in general, as you noticed (with 
> page locals). Also Cocoon.handleContinuation() is an internal function 
> that shouldn't be called except by Cocoon itself. You're also not 
> passing correct arguments to it.

Hmmm:

public void handleContinuation(String kontId, Scriptable parameters)

If we only want it to be callable by Cocoon itself, why is it public? 
Does it need to be public for the Javascript stuff?

On a side note, I wonder how much stuff that should be private is 
actually public.


Tony


Re: Call continuations from flow instead of sitemap

Posted by Leszek Gawron <ou...@wlkp.org>.
On Sat, Apr 03, 2004 at 11:17:42PM -0800, Christopher Oliver wrote:
> >contManager = null;
> >try {
> > contManager = cocoon.getComponent
> >( "org.apache.cocoon.components.flow.ContinuationsManager" );
> >var wk = contManager.lookupWebContinuation( continuationId );
> >} finally {
> > if ( contManager != null ) 
> >   cocoon.releaseComponent( contManager );    
> >}
> >
> >cocoon.handleContinuation( wk.getContinuation() );
> >	lg
> > 
> >
> Uh, it doesn't actually work properly in general, as you noticed (with 
> page locals). Also Cocoon.handleContinuation() is an internal function 
> that shouldn't be called except by Cocoon itself. You're also not 
> passing correct arguments to it.
The source of cocoon.handleContinuation() couldn't be simpler :
FOM_Cocoon.prototype.handleContinuation = function(k, wk) {
    k(wk);
}

so I could do 
c = wk.getContinuation();

c();



Vadim proposed c(c) but this threw exception about uninitialized FOM_Request
(see my other mails in this thread)


Why is it so I can catch the Continuation in flow itself and then invoke it
but I cannot run a continuation that I did not catch myself?


You've written that the arguments I pass to handleContinuation are
incorrect. What is this second argument for ?

> 
> If you really think it should be possible to lookup a web continuation 
> and invoke it from a flowscript then make a proposal and see what people 
> think. If it turns out to be a good idea then a proper implementation 
> can be provided. However, currently it is _not_ a supported feature.
Sould 
I start a poll? make a bugzilla entry?
regards,
	lg

-- 
            __
         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/       ouzo@wlkp.org           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |


Re: Call continuations from flow instead of sitemap

Posted by Christopher Oliver <re...@verizon.net>.
Leszek Gawron wrote:

>On Sat, Apr 03, 2004 at 03:55:54PM -0800, Christopher Oliver wrote:
>  
>
>>Sylvain Wallez wrote:
>>
>>    
>>
>>>Christopher Oliver wrote:
>>>
>>>      
>>>
>>>>These ContinuationsManager API should _not_ be used in a flowscript. 
>>>>Use the sitemap to invoke your continuation, please.
>>>>        
>>>>
>>>
>>>Although I found this hacky, is there any technical reasons that 
>>>prevents this to work?
>>>
>>>Sylvain
>>>
>>>      
>>>
>>Yes, the FOM_Cocoon object requires special setup before invoking a 
>>continuation or entry point function.
>>    
>>
>
>if so , why does this code work (under condition that you do not use page
>local variables):
>
>contManager = null;
>try {
>  contManager = cocoon.getComponent
>( "org.apache.cocoon.components.flow.ContinuationsManager" );
> var wk = contManager.lookupWebContinuation( continuationId );
>} finally {
>  if ( contManager != null ) 
>    cocoon.releaseComponent( contManager );    
>}
>
>cocoon.handleContinuation( wk.getContinuation() );
>	lg
>  
>
Uh, it doesn't actually work properly in general, as you noticed (with 
page locals). Also Cocoon.handleContinuation() is an internal function 
that shouldn't be called except by Cocoon itself. You're also not 
passing correct arguments to it.

If you really think it should be possible to lookup a web continuation 
and invoke it from a flowscript then make a proposal and see what people 
think. If it turns out to be a good idea then a proper implementation 
can be provided. However, currently it is _not_ a supported feature.

Regards,

Chris

Re: Call continuations from flow instead of sitemap

Posted by Leszek Gawron <ou...@wlkp.org>.
On Sat, Apr 03, 2004 at 03:55:54PM -0800, Christopher Oliver wrote:
> Sylvain Wallez wrote:
> 
> >Christopher Oliver wrote:
> >
> >>These ContinuationsManager API should _not_ be used in a flowscript. 
> >>Use the sitemap to invoke your continuation, please.
> >
> >
> >
> >Although I found this hacky, is there any technical reasons that 
> >prevents this to work?
> >
> >Sylvain
> >
> Yes, the FOM_Cocoon object requires special setup before invoking a 
> continuation or entry point function.

if so , why does this code work (under condition that you do not use page
local variables):

contManager = null;
try {
  contManager = cocoon.getComponent
( "org.apache.cocoon.components.flow.ContinuationsManager" );
 var wk = contManager.lookupWebContinuation( continuationId );
} finally {
  if ( contManager != null ) 
    cocoon.releaseComponent( contManager );    
}

cocoon.handleContinuation( wk.getContinuation() );
	lg
-- 
            __
         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/       ouzo@wlkp.org           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |


Re: Call continuations from flow instead of sitemap

Posted by Christopher Oliver <re...@verizon.net>.
Sylvain Wallez wrote:

> Christopher Oliver wrote:
>
>> These ContinuationsManager API should _not_ be used in a flowscript. 
>> Use the sitemap to invoke your continuation, please.
>
>
>
> Although I found this hacky, is there any technical reasons that 
> prevents this to work?
>
> Sylvain
>
Yes, the FOM_Cocoon object requires special setup before invoking a 
continuation or entry point function.

Chris

Re: Call continuations from flow instead of sitemap

Posted by Sylvain Wallez <sy...@apache.org>.
Christopher Oliver wrote:

> These ContinuationsManager API should _not_ be used in a flowscript. 
> Use the sitemap to invoke your continuation, please.


Although I found this hacky, is there any technical reasons that 
prevents this to work?

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Re: Call continuations from flow instead of sitemap

Posted by Christopher Oliver <re...@verizon.net>.
These ContinuationsManager API should _not_ be used in a flowscript. Use 
the sitemap to invoke your continuation, please.

Is it possible to solve your problem by using a helper function to send 
the page:

function sendPageAndWait(uri, biz, ttl) {
  cocoon.response.setHeader( "Expires", "-1" );
  cocoon.response.setHeader( "Cache-Control", "no-cache" );
  cocoon.response.setHeader( "Pragma", "no-cache" );
  return cocoon.sendPageAndWait(uri, biz, ttl);
}

Or perhaps Reinhard's intercepted flowscript could help here...

 
Chris



Leszek Gawron wrote:

>On Thu, Apr 01, 2004 at 02:39:05PM -0500, Vadim Gritsenko wrote:
>  
>
>>Leszek Gawron wrote:
>>
>>    
>>
>>>I have this snipped in one of my .js files :
>>>
>>>
>>>      
>>>
>>...
>>
>>    
>>
>>>function runContinuation( action ) {
>>>
>>>
>>>      
>>>
>>Provided that "action" contains continuation ID and not actual 
>>continuation object... you need to lookupWebContinuation from the 
>>ContinuationsManager component, this will give you WebContinuation 
>>object. Once you have it... Something like this should be able to invoke it:
>>
>>   var wk = contManager.lookupWebContinuation(action);
>>   var c = wk.getContinuation();
>>   c(c);
>>    
>>
> You have to do c(); Otherwise you get some errors about uninitialized
>FOM_Request. This also does not work if you have page local variables. I have
>filed a bugzilla report at
>http://issues.apache.org/bugzilla/show_bug.cgi?id=28179
>
>	lg
>  
>


Re: Call continuations from flow instead of sitemap

Posted by Leszek Gawron <ou...@wlkp.org>.
On Thu, Apr 01, 2004 at 02:39:05PM -0500, Vadim Gritsenko wrote:
> Leszek Gawron wrote:
> 
> >I have this snipped in one of my .js files :
> > 
> >
> ...
> 
> >function runContinuation( action ) {
> > 
> >
> 
> Provided that "action" contains continuation ID and not actual 
> continuation object... you need to lookupWebContinuation from the 
> ContinuationsManager component, this will give you WebContinuation 
> object. Once you have it... Something like this should be able to invoke it:
> 
>    var wk = contManager.lookupWebContinuation(action);
>    var c = wk.getContinuation();
>    c(c);
 You have to do c(); Otherwise you get some errors about uninitialized
FOM_Request. This also does not work if you have page local variables. I have
filed a bugzilla report at
http://issues.apache.org/bugzilla/show_bug.cgi?id=28179

	lg
-- 
            __
         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/       ouzo@wlkp.org           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |


RE: Call continuations from flow instead of sitemap

Posted by Leszek Gawron <lg...@mobilebox.pl>.
> Provided that "action" contains continuation ID and not actual
> continuation object... you need to lookupWebContinuation from the
> ContinuationsManager component, this will give you WebContinuation
> object. Once you have it... Something like this should be able to invoke it:
> 
>     var wk = contManager.lookupWebContinuation(action);
>     var c = wk.getContinuation();
>     c(c);

This is the working code which I'd like to wikify:

var contManager = null;
try {
  contManager = cocoon.getComponent(
"org.apache.cocoon.components.flow.ContinuationsManager" );
 var wk = contManager.lookupWebContinuation( continuationId );
} finally {
  if ( contManager != null ) 
    cocoon.releaseComponent( contManager );    
}
var c = wk.getContinuation();
c(c);


I do not know how can I display the default "invalid continuation" screen.
Could you help?

	lg


Re: Call continuations from flow instead of sitemap

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Leszek Gawron wrote:

>I have this snipped in one of my .js files :
>  
>
...

>function runContinuation( action ) {
>  
>

Provided that "action" contains continuation ID and not actual 
continuation object... you need to lookupWebContinuation from the 
ContinuationsManager component, this will give you WebContinuation 
object. Once you have it... Something like this should be able to invoke it:

    var wk = contManager.lookupWebContinuation(action);
    var c = wk.getContinuation();
    c(c);


Vadim