RE: [PROPOSAL] allow to invoke continuations from flow instead of sitemap
Leszek Gawron wrote: Hello, Christofer Oliver has written [1] that I should make a proposal so here it is: What do you think about the flow ability to call a continuation knowing the continuation id. It should look something like: 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(), wk ); Right now this is not a supported feature (it works when one does not use page local variables). Hmm, I'm not sure what to think about this, but: The usage: - when he continuation id is stored somewhere else than request uri (for example request parameter) This can be done very easy. Change the place where you create the link and change the getting the cont. id logic in the sitemap by using a different input module. - when one gets 2 continuation ids and chooses one basing on some external info Can you give an example, when you need this? - Just curious. - when one wants to do something for each continuation resumed (for example set Cache-control header). Can you expand a little bit more on this? For all above examples you have to code logic in sitemap. I think this is not as elegant as if you could have whole logic in a flowscript At the current state of this discussion I would say, let's not add this feature to flow. If you want to do such things, write some custom components (input modules, actions etc.) and use them at appropriate places. But perhaps with some more info, I see things in different light. Carsten
Re: [PROPOSAL] allow to invoke continuations from flow instead of sitemap
On Tue, Apr 06, 2004 at 12:59:10PM +0200, Carsten Ziegeler wrote: - when one gets 2 continuation ids and chooses one basing on some external info Can you give an example, when you need this? - Just curious. Me ? Nowhere - that was just a rough example .. - when one wants to do something for each continuation resumed (for example set Cache-control header). Can you expand a little bit more on this? If you use IE (I do not know how other browsers handle this) if you serve a page without client cache turned off you make a security hole (IE caches everything and serves even after user has logged out). See the code attached below. The main method marks all function, continuation and view requests not cacheable. What I request is the proper handling of code in runContinuation fuction. For all above examples you have to code logic in sitemap. I think this is not as elegant as if you could have whole logic in a flowscript At the current state of this discussion I would say, let's not add this feature to flow. If you want to do such things, write some custom components (input modules, actions etc.) and use them at appropriate places. But perhaps with some more info, I see things in different light. If you write actions you split your logic into 2 areas: actions and flow. Right now I set Cache-control header for continuation with set-header action. The code (assume every non internal uri goes to main method ): 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 !isContinuation( action ) ) { loginInternal(); } invoke( action ); } function invoke( action ) { print( action: + action ); if ( isContinuation( action ) ) { var id = extractContinuationId( action ); print( da id: + id ); runContinuation( id ); } else { func = this[ action ]; if ( func != undefined ) func.apply( this ); else cocoon.sendPage( action, {} ); } } function isContinuation( action ) { var id = new java.lang.String( action ); return ( id.endsWith( .continue ) || id.endsWith( .cont ) ); } function extractContinuationId( action ) { var id = new java.lang.String( action ); var pos = id.indexOf( . ); return id.substring( 0, pos ); } function runContinuation( continuationId ) { 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( wk ); } function loginInternal() { var form = new Form( forms/login_d.xml ); var model = form.getModel(); form.validator = loginValidator; form.showForm( form/login, {} ); } function loginValidator( form ) { var query = nTerApi.session.createQuery( from User where name = :name and password = :password ); query.setString( name, form.getWidget( username ).getValue() ); query.setString( password, form.getWidget( password ).getValue() ); var list = query.list(); if ( list.size() == 0 ) { form.getWidget( messages ).addMessage( Bdny uytkownik lub haso! ); return false; } user = list.get( 0 ); return true; } function login() { user = null; loginInternal(); cocoon.sendPage( /nTer/view/welcome.jx, {} ); } function logout() { user = null; cocoon.session.invalidate(); cocoon.redirectTo( /nTer/welcome.do, {} ); } -- __ | / \ |Leszek Gawron// \\ \_\\ //_/ [EMAIL PROTECTED] _\\()//_ .'/()\'. Phone: +48(501)720812 / // \\ \ \\ // recursive: adj; see recursive | \__/ |
RE: [PROPOSAL] allow to invoke continuations from flow instead of sitemap
Leszek Gawron wrote: On Tue, Apr 06, 2004 at 12:59:10PM +0200, Carsten Ziegeler wrote: - when one gets 2 continuation ids and chooses one basing on some external info Can you give an example, when you need this? - Just curious. Me ? Nowhere - that was just a rough example .. Who else if not you :) - when one wants to do something for each continuation resumed (for example set Cache-control header). Can you expand a little bit more on this? If you use IE (I do not know how other browsers handle this) if you serve a page without client cache turned off you make a security hole (IE caches everything and serves even after user has logged out). See the code attached below. The main method marks all function, continuation and view requests not cacheable. What I request is the proper handling of code in runContinuation fuction. For all above examples you have to code logic in sitemap. I think this is not as elegant as if you could have whole logic in a flowscript At the current state of this discussion I would say, let's not add this feature to flow. If you want to do such things, write some custom components (input modules, actions etc.) and use them at appropriate places. But perhaps with some more info, I see things in different light. If you write actions you split your logic into 2 areas: actions and flow. That's true, but that are imho two different concerns: the page flow and the continuation handling. Now, perhaps someone else can help here a little bit. I discusses the contination handling in flow with Ovidiu a little bit during the last ApacheCon and I think he mentioned that it's very easy to extend the current handling by defining an own component (extending the existing one). Using this approach, you can e.g. store the cont id in a cookie or somewhere else, or you can do checks if the continuation is still ok and perhaps also do your client cache handling. You do this once, in this central component and never have to touch all your flow based applications. They simply work the way you expect them to work. (I hope, I'm not wrong with this approach...) Carsten
Re: [PROPOSAL] allow to invoke continuations from flow instead of sitemap
Leszek Gawron dijo: If you use IE (I do not know how other browsers handle this) if you serve a page without client cache turned off you make a security hole (IE caches everything and serves even after user has logged out). Very smart browser! ROTFL! See the code attached below. The main method marks all function, continuation and view requests not cacheable. What I request is the proper handling of code in runContinuation fuction. For all above examples you have to code logic in sitemap. I think this is not as elegant as if you could have whole logic in a flowscript At the current state of this discussion I would say, let's not add this feature to flow. If you want to do such things, write some custom components (input modules, actions etc.) and use them at appropriate places. But perhaps with some more info, I see things in different light. If you write actions you split your logic into 2 areas: actions and flow. Right now I set Cache-control header for continuation with set-header action. The code (assume every non internal uri goes to main method ): var user = null; function main( action ) { cocoon.response.setHeader( Expires, -1 ); cocoon.response.setHeader( Cache-Control, no-cache ); cocoon.response.setHeader( Pragma, no-cache ); All these 3 instructions, can be setted in a the HTML style transformer instead of doing it in Flow. If not you need to write it over and over. if ( user == null !isContinuation( action ) ) { loginInternal(); } invoke( action ); } function invoke( action ) { print( action: + action ); if ( isContinuation( action ) ) { var id = extractContinuationId( action ); print( da id: + id ); runContinuation( id ); } else { func = this[ action ]; if ( func != undefined ) func.apply( this ); else cocoon.sendPage( action, {} ); } } function isContinuation( action ) { var id = new java.lang.String( action ); return ( id.endsWith( .continue ) || id.endsWith( .cont ) ); } function extractContinuationId( action ) { var id = new java.lang.String( action ); var pos = id.indexOf( . ); return id.substring( 0, pos ); } function runContinuation( continuationId ) { 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( wk ); } In the below code, can you better use the standard authentication-fw. the auth-fw can also work with flow: function loginInternal() { var form = new Form( forms/login_d.xml ); var model = form.getModel(); form.validator = loginValidator; form.showForm( form/login, {} ); } function loginValidator( form ) { var query = nTerApi.session.createQuery( from User where name = :name and password = :password ); query.setString( name, form.getWidget( username ).getValue() ); query.setString( password, form.getWidget( password ).getValue() ); var list = query.list(); if ( list.size() == 0 ) { form.getWidget( messages ).addMessage( Błędny użytkownik lub hasło! ); return false; } user = list.get( 0 ); return true; } function login() { user = null; loginInternal(); cocoon.sendPage( /nTer/view/welcome.jx, {} ); } function logout() { user = null; cocoon.session.invalidate(); cocoon.redirectTo( /nTer/welcome.do, {} ); }
Re: [PROPOSAL] allow to invoke continuations from flow instead of sitemap
On Tue, Apr 06, 2004 at 05:32:25AM -0600, Antonio Gallardo wrote: Leszek Gawron dijo: If you use IE (I do not know how other browsers handle this) if you serve a page without client cache turned off you make a security hole (IE caches everything and serves even after user has logged out). Very smart browser! ROTFL! At last if you do not close your browser window. That is a real problem because even if you log out and login again sometimes requesting for examples /myApp/showProjects.do you do not see your server being hit. The code (assume every non internal uri goes to main method ): var user = null; function main( action ) { cocoon.response.setHeader( Expires, -1 ); cocoon.response.setHeader( Cache-Control, no-cache ); cocoon.response.setHeader( Pragma, no-cache ); All these 3 instructions, can be setted in a the HTML style transformer instead of doing it in Flow. If not you need to write it over and over. HTML Transformer sets response headers? I do not think so. META tags maybe - but IE docs say explicitly that headers are preffered over meta tags In the below code, can you better use the standard authentication-fw. the auth-fw can also work with flow: I do not use authentication-fw intentionally as I want to have an acces to a complete user object ( I use hibernate ). This is also a reason I do not use container authentication - it gives me only username and I would have to fetch the user data every time. lg -- __ | / \ |Leszek Gawron// \\ \_\\ //_/ [EMAIL PROTECTED] _\\()//_ .'/()\'. Phone: +48(501)720812 / // \\ \ \\ // recursive: adj; see recursive | \__/ |
Re: [PROPOSAL] allow to invoke continuations from flow instead of sitemap
On Tue, Apr 06, 2004 at 01:32:58PM +0200, Carsten Ziegeler wrote: That's true, but that are imho two different concerns: the page flow and the continuation handling. Now, perhaps someone else can help here a little bit. I discusses the contination handling in flow with Ovidiu a little bit during the last ApacheCon and I think he mentioned that it's very easy to extend the current handling by defining an own component (extending the existing one). Using this approach, you can e.g. store the cont id in a cookie or somewhere else, or you can do checks if the continuation is still ok and perhaps also do your client cache handling. You do this once, in this central component and never have to touch all your flow based applications. They simply work the way you expect them to work. (I hope, I'm not wrong with this approach...) Seems interesting. The main reason I'm pushing for this feature is that it looks elegant to me (maybe it is not - prove me wrong) and it ALMOST works. I can run continuations from flow with no problem under condition that there is no page local variables. Only those page local variables .. lg -- __ | / \ |Leszek Gawron// \\ \_\\ //_/ [EMAIL PROTECTED] _\\()//_ .'/()\'. Phone: +48(501)720812 / // \\ \ \\ // recursive: adj; see recursive | \__/ |