[Seaside] Where to put a shopping cart
Nevin Pratt
nevin at smalltalkpro.com
Tue Mar 25 14:23:27 CET 2003
I'm struggling a bit in deciding the best place to store an instance of
my ShoppingCart class.
For a "normal" web app, I would store it as an attribute of the
HttpSession. However, Seaside's notion of a Session is a bit different.
For a classic client/server app (not a web app), I would do thus:
In a classic client/server approach (one that has no notion of the web),
I typically arrange the UI screens to be a hierarchy of visual
components, where the "top-most" component handles the main menu and a
few other things. In such an architecture, there is only one instance
of the top-most component throughout the entire duration of the
"program", and hence that instance can hold something like a shopping
cart, and be asked for the cart by any subordinate component with
something like the following:
self topComponent shoppingCart.
Any component can ask for it's immediate parent thus:
self parentComponent.
And #topComponent is implemented something like thus:
topComponent
self parentComponent notNil ifTrue: [^self parentComponent
topComponent].
^self
Now, for a Seaside app, it looks like I could duplicate this general
architecture by having only one registered entry point for the program
(i.e., only have one Seaside "application"), and then having that
application embed subordinate screens as separately embedded components
(like the MultiCounter does, for example). If I did this, then the
shopping cart could simply be an instance variable of the one-and-only
application.
However, such an approach doesn't appear to let me use bookmarks (am I
wrong?). Because of this, I've been having most of the individual web
screens be separate Seaside applications (each screen registered
separately via http://localhost:9090/seaside/config ). But, when you do
this, you lose application coherance, because it suddently becomes many
individual applications instead of a single application-- and now those
many individual applications need access to a common "Global" like a
shopping cart.
Suggestions?
Thanks in advance,
Nevin
More information about the Seaside
mailing list