The only response we got on the users list was "Your doing it wrong". We need some better understanding of how Flowscript handles the global variables.

The docs say they are treated like session variables, but even within the same request they seem to be cleared after a call to the flowscript is finished and the sendPage has been called. We are dealing with a page that aggregates a set of information from different components together, but relies on some of the same initial setup for all the aggregated parts.

Global flowscript variables are not behaving as expected. We can adjust to explicitly using cocoon.session instead of global flowscript variables. If that is the preferred case, we need to adjust the docs to make it clear what to expect.

--
Design is a funny word. Some people think design means how it looks.
But of course, if you dig deeper, it's really how it works.

                                                      -- Steve Jobs

--- Begin Message ---
Hey gang,

I'd like your input on some anomalous behaviour I am experiencing in
my 2.1.7 flowscript.

I have a function defined in javascript that expects a global var to
be available at the point in time it is invoked. However, this is not
the case -- the function is unable to see the recently initialized
global variable. The main entry point in my example is the URI
"login". The area where the error occurs is in "accessFoo()".

Normal "login" processing occurs in my flowscript...

var _component = new AnAvalonComponent();
var _globalFoo;
var _initFlag;

function login()
{
  if (_globalFoo == undefined) initSession();
  else _globalFoo.reset();
  cocoon.sendPage("pages/displayHome.xsp");
}

function initSession()
{
  if (_globalFoo == undefined)
  {
    _globalFoo= new FooObject();
    var session = cocoon.session;
  }
}

function accessFoo()
{
  var bean = _component.getBean(_globalFoo);
  cocoon.sendPage("pages/displayBean.xsp", {"bean ":bean});
}

Here is my sitemap...

    <map:pipelines>
        <map:pipeline internal-only="true">
            <map:match pattern="pages/displayHome.xsp">
                <map:aggregate element="page">
                    <map:part src="cocoon:/header.xsp"/>
                    <map:part src="cocoon:/do.accessFoo"/>
                    <map:part src="cocoon:/footer.xsp"/>
                </map:aggregate>
            </map:match>

            <map:match pattern="do.accessFoo">
                <map:call function="accessFoo"/>
            </map:match>

            <map:match pattern="pages/displayBean.xsp">
                <map:generate src="bean.jx" type="jx"/>
                <map:serialize type="xml"/>
            </map:match>
    </map:pipelines>

    <map:pipelines>
            <map:match pattern="pages/login.xsp">
                <map:call function="login"/>
            </map:match>
    </map:pipelines>

The problem occurs when accessFoo() attempts to retrieve the recently
initialized _globalFoo object. The value of _globalFoo in that method
is "undefined", even though the initSession() was invoked prior in the
pipeline before reaching accessFoo() -- eg. pages/displayBean.xsp
complains that the "bean" is "undefined".

Can anyone shed some light into why this is happening? I have a
feeling I know what might be causing the problem but I'm looking for
input from more experienced cocoon developers.

Is there an alternative or "best-practice" recommendation as far as
initializing and accessing global vars in the flowscript (perhaps a
continuation object, or strictly passing objects in the pipeline, or
using the cocoon.session to pass the references)?

Thanks in advance, cheers!
S.Lee

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




--- End Message ---

Reply via email to