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: Arturo PĂ©rez <email@hidden>
- Date: Thu, 17 Jul 2003 22:40:57 -0400
On Thursday, July 17, 2003, at 06:36 PM, Jonathan Rochkind wrote:
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 );
This is how we did things as well. It got particularly driven home
when some bright bulb decided to put
session() into an EO. I don't even want to think about why they
thought that was a good idea. In any case...
The pattern above fails for frameworks (at least under 4.5). That is,
when you customize the Session object to
include these sorts of things and then break up an application into
frameworks you'll find that the frameworks
won't know about the Session instance variables you added. In that
case, you have to do the
SomeComponent nextPage = (SomeComponent) pageWithName("SomeComponent");
nextPage.setSomeValue( myOwnSomeValue );
I personally prefer the following idiom instead (same difference, as
they say)
WOComponent nextPage = pageWithName("SomeComponent");
nextPage.takeValueForKey( myOwnSomeValue, "someValue" );
because it makes it easier to "borrow" code and move things around. I
believe I'm aware of all the
downsides.
-------
WebObjects in Philadelphia. You want a cheesesteak with that?
_______________________________________________
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.