cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <>
Subject Re: Storing object in context with flow
Date Mon, 05 Jan 2004 10:46:02 GMT

On 4 Jan 2004, at 17:15, Upayavira wrote:

> I have an object that is used by all pages to present static data to 
> pages using JXtemplate, so
> cocoon.sendPageAndWait("page", {"static", 
> cocoon.context.getAttribute("StaticObject")});
> How can I get an object into the context, once, at server startup, 
> without subclassing CocoonServlet?

I did something like this (top level in the script):

// create the context object if it does not exist
if (cocoon.context.resourceToDo == null) { ("Constructing a new JobManager");
	cocoon.context.setAttribute ("resourceToDo", new ());

// Add the JobManager to each User's Session so it is notified when the 
User logs or times out
cocoon.session.setAttribute ("resourceToDo", 
cocoon.context.getAttribute ("resourceToDo"));

// make it available as a global variable
var resourceToDo = cocoon.session.getAttribute ("resourceToDo");

ie. I wanted the JobManager to be set up only once for all users, to be 
in each User's session so it can receive HttpSessionBindingEvent 
(JobManager implements HttpSessionBindingListener) and be available as 
a local JS variable.

You probably do not need all of these steps.


regards Jeremy

View raw message