You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Leszek Gawron <lg...@mobilebox.pl> on 2006/08/01 09:47:53 UTC

Re: Weird Javascript error in continuations

Simone Gianni wrote:
> Hi Toby,
> I think you are right. What a continuation does (should do) is dump the
> local variables and restore them before restarting the flow. This means
> that if you write var a = 1; then create a continuation, when you return
> to that continuation a should be 1 again, even if in other continuations
> it has been changed to 2,3 or 4.
> 
> There is surely one known limitation to this : if you say var bean = new
> MyBean(); bean.setX(1); then produce a continuation, then after the
> continuation you call bean.setX(2), even if you go back to the previous
> continuation you will find that bean.getX() == 2, because the LOCAL
> VARIABLE is still your bean, but it's internal state is not manageable
> by the continuation (more formally, your local variable is a pointer to
> a bean, which is correctly restored when you go back to the
> continuation, but the data it points to is not serialized/deserialized
> by the continuation).
> 
> But this is not your case, in this case you are setting a simple
> javascript variable, so it should work as you say, at least AFAIK :)
> 
> Please, file a bug about it.
I think it works OK. What is a local variable different from a bean?

Continuations are for managing flow, not keeping full state because it 
would consume too much resources. In 99% you do not need variables to 
have values bound to a specific continuation. Still you have an option 
to do so:

var pageLocal = cocoon.createPageLocal();
pageLocal.a = 1;

a PageLocal will have different values for different continuations. 
Please mind resource implications for that approach.

-- 
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