RE: EO Object Lifespan / Editing Context (Goodbye Bill)
RE: EO Object Lifespan / Editing Context (Goodbye Bill)
- Subject: RE: EO Object Lifespan / Editing Context (Goodbye Bill)
- From: Jonathan Rochkind <email@hidden>
- Date: Thu, 17 Jul 2003 17:36:07 -0500
Well, I think that needs some qualifications.
At 09:30 AM 7/18/2003 +1200, Ray Ackland wrote:
To simplify what the others were saying, if you want some object to be
"passed around" between multiple pages, the best way of doing this is to
make that object an instance variable in your Session class.
I wouldn't neccesarily say that's true, myself. Putting it in the Session
is certainly one way to do that. But as a design choice, I wouldn't put it
in the session unless it can really be thought of as an attribute of the
Session. For instance, the currently logged in user is an attribute of the
Session. A shopping basket is an attribute of the Session---it belongs to
the current session, this makes sense.
Other things that you may want to pass from one page to another (say, the
section of a catalog the user is currently looking at) are not really
attributes of a session, are are best passed from page to page... simply by
passing them from page to page.
SomeComponent nextPage = (SomeComponent) pageWithName("SomeComponent");
nextPage.setSomeValue( myOwnSomeValue );
You can reference your session object from within WO Builder, and access
its variables (eg the Member object) from any of your pages.
True enough.
Similarly, if you need any objects to be shared between multiple sessions,
have it as an instance variable in the Application class.
If the object you are talking about is an EO (that is, an object that is
persistent in the db, through the EOF framework), this is a bad idea on a
variety of grounds. An EO belongs to a specific Editing Context (EC). A
typical editing context belongs to a certain session---and unless you are
using an EOSharedEditingContext (not neccesarily for the beginner), it's
dificult and not reccomended to do otherwise. There are a bunch of reasons
storing an EO in Application state is really not a good idea.
--Jonathan
r.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.