Thx Mark and Leszek, very enlightning! Might be worth documenting a little :-) 


> 
> Mark Lundquist wrote:
> > 
> > On Aug 1, 2006, at 1:07 AM, Ard Schrijvers wrote:
> > 
> >> I never used (saw :-) ) this createPageLocal untill now,
> > 
> > Huh, I sent a reply on this thread suggesting 
> createPageLocal() last 
> > week, oh well... :-)
> > 
> >> and looked at 
> http://cocoon.apache.org/2.1/userdocs/flow/api.html, but 
> >> I don't really get this one. You don't need a 
> sendPageAndWait using 
> >> this one? Otherwise, the sendPageAndWait would hold the normal 
> >> continuation, right? I  don't see what I gain with 
> createPageLocal if 
> >> I still need a sendPageAndWait which creates a 
> continuation. Could you 
> >> explain a little more, because I am very curious,
> > 
> > It's still a "normal continuation" created by sendPageAndWait.  The 
> > thing that is special is not the continuation, but the object.
> > 
> > var state = createPageLocal();
> > state.step = 'Step 1';
> > cocoon.sendPageAndWait('foo');
> > ...
> > state.step = 'Step 2';
> > cocoon.sendPageAndWait ('bar');
> > 
> > Now if I hit the 'back' button after the second page, then 
> continue from 
> > the first page, when the first continuation is reinvoked 
> then state.step 
> > will have the value 'Step 1'.  Does that example help?
> Of course if state was declared like this:
> 
> var state = {}
> 
> so an "ordinary" variable then if the first continuation is reinvoked 
> the state.step will have the 'Step 2' value.
> 
> Simply speaking: page local is a special variable that has different 
> values in different continuations. This is both neat and dangerous in 
> terms of resource consumption.
> 
> > 
> > BTW, resource considerations aside, you need "global" 
> > (continuation-independent) state for things like being able 
> to detect 
> > when the user has re-submitted a form (e.g., the "Yes, 
> charge my credit 
> > card now!" form :-)
> 
> 
> I know two ways of doing that:
> 1. simple one: redirect to a new page after the transaction has been 
> completed. This kills continuations continuity (and sucks) 
> but saves you 
> from user pressing F5 and accidentaly resubmitting the whole 
> form (and 
> reinvoking your transaction)
> 
> 2. token based. Before you enter some form you generate a 
> token that is 
> invalidated after transaction finishes. If user resubmits the 
> form - the 
> token is already invalid and instead of rerunning the transaction the 
> user is informed that no action will take place.
> 
> Unfortunatelly there is no automatic support in cocoon for any of 
> solutions presented above.
> 
> -- 
> Leszek Gawron                                      
> [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to