You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Adam Ratcliffe <ad...@mrigitech.com> on 2005/01/20 05:31:43 UTC

[flow] global variable values lost between invocations

I have a flowscript where I set the value of a global variable, call
cocoon.session to create a session, but find
that it's value is undefined when I next invoke a top-level function in the
script.

An excerpt from the script where the variable's value is set is:

    var mapContext;
    ....
    function createContext() {
        mapContext = new MapContext();

        var session = cocoon.session;

        var redirectURI = cocoon.request.getParameter("redirectURI");

        cocoon.redirectTo(redirectURI);
    }

Any ideas on the possible causes of this behaviour would be much
appreciated.

Cheers
Adam

RE: [flow] global variable values lost between invocations

Posted by Adam Ratcliffe <ad...@mrigitech.com>.
Hi Mark,

I'm running 2.1.6.  I wrote a simple test case in an independent flowscript
and that works
fine, didn't need to call cocoon.session as you suggested.

In other ideas?

Cheers
Adam

> -----Original Message-----
> From: Mark Lundquist [mailto:ml@wrinkledog.com]
> Sent: Thursday, 20 January 2005 5:47 p.m.
> To: users@cocoon.apache.org
> Subject: Re: [flow] global variable values lost between invocations
>
>
>
> On Jan 19, 2005, at 8:31 PM, Adam Ratcliffe wrote:
>
> > I have a flowscript where I set the value of a global variable, call
> > cocoon.session to create a session, but find
> > that it's value is undefined when I next invoke a top-level function
> > in the script.
> >  
> > An excerpt from the script where the variable's value is set is:
> >  
> >     var mapContext;
> >     ....
> >     function createContext() {
> >         mapContext = new MapContext();
> >
> >         var session = cocoon.session;
>
> What version of Cocoon are you running?  A session is automatically
> created when the global variable is declared, you don't have to
> reference cocoon.session anymore... but that might be new in 2.1.6...
>
> —ml—
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>


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


RE: [flow] global variable values lost between invocations - more info

Posted by Adam Ratcliffe <ad...@mrigitech.com>.
Hi Mark,

I just did a quick test and found that the problem is occurring because the
2nd function
invocation, where the global is tested for the previously set value, is
coming from a
different sitemap.

Does this mean that each sitemap that uses a flowscript has its own separate
global variable
scope?

If so, is this a design issue that needs to be resolved i.e. where access to
shared globals
is required all matching is done in the same sitemap?

Thanks for your help,
Adam


> -----Original Message-----
> From: Mark Lundquist [mailto:ml@wrinkledog.com]
> Sent: Thursday, 20 January 2005 5:47 p.m.
> To: users@cocoon.apache.org
> Subject: Re: [flow] global variable values lost between invocations
>
>
>
> On Jan 19, 2005, at 8:31 PM, Adam Ratcliffe wrote:
>
> > I have a flowscript where I set the value of a global variable, call
> > cocoon.session to create a session, but find
> > that it's value is undefined when I next invoke a top-level function
> > in the script.
> >  
> > An excerpt from the script where the variable's value is set is:
> >  
> >     var mapContext;
> >     ....
> >     function createContext() {
> >         mapContext = new MapContext();
> >
> >         var session = cocoon.session;
>
> What version of Cocoon are you running?  A session is automatically
> created when the global variable is declared, you don't have to
> reference cocoon.session anymore... but that might be new in 2.1.6...
>
> —ml—
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>


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


Re: [flow] global variable values lost between invocations

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jan 19, 2005, at 8:31 PM, Adam Ratcliffe wrote:

> I have a flowscript where I set the value of a global variable, call 
> cocoon.session to create a session, but find
> that it's value is undefined when I next invoke a top-level function 
> in the script.
>  
> An excerpt from the script where the variable's value is set is:
>  
>     var mapContext;
>     ....
>     function createContext() {
>         mapContext = new MapContext();
>
>         var session = cocoon.session;

What version of Cocoon are you running?  A session is automatically 
created when the global variable is declared, you don't have to 
reference cocoon.session anymore... but that might be new in 2.1.6...

—ml—


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