When I've wanted to maintain a variable across different transactions I
usually set it in the page's __init__, the only problem with this is
that it make the variable the same for everyone, so I am not entirely
sure that it is what you are looking for.
Date: Thu, 01 May 2003 23:17:43 -0400
From: Peter Lyons <pete@...>
To: Tavis Rudd <tavis@...>
Subject: Re: [Webware-discuss] WebObjects stateful components
By stateful, I mean retain state across multiple transactions. The
thread safety issue is related but distinct. From what you are saying
and tests I ran, the Webware component model seems to be analogous to a
WebObjects stateless component. This means a small number of instances
are created to handle all transactions in all sessions, but still
ensuring thread safety for the duration of a request. In WebObjects, a
standard stateful WOComponent has 1 instance dedicated to each session,
so you can, for example, increment a hit counter in awake() and it will
only reflect times a given user has hit that page, as oppesed to the
same thing in a stateless component, which would reflect total number of
hits across all sessions. So it seems that there is no direct analog to
a stateful WOComponent. Does that seem correct?
I've been adding request-specific state into the request object
directly using request().setField(), which works quite well for me, but
a separate container in the transaction might be cleaner and more
flexible, so I'll try it out.