[Seaside] Component lifecycle and how to use announcement on a model
Tim Mackinnon
tamackinnon at gmail.com
Wed Aug 11 22:23:42 UTC 2010
Hi guys - as I drill through my "once simple" toy application (actually
its not that bad - particularly compared to the java/gwt stuff I get at
work) - I keep coming up with features that excercise new parts of
seaside/pharo.
I currently have a "model" that I store as a class variable on my root
component. As i've split out bits of functionality from my app and
moved them into sub-components, I've instantiated those components with
that same shared model so they could render different parts of it. I
think this is the right style...?
Anyway in adding a new "Remove button" feature, it felt like it should
live in an existing items list component - however a model update can
require an ajax update to redraw my model state so everything looks
right (and its my main component that coordinates this).
So it seemed like a perfect fit for Announecments - my root could
subscribe to a model change and then coordinate the ajax update of the
correct components.
I did this , and then started getting updates all over the place (even
unexpectedly) - I'm thinking that when I subscribe to my Announcements,
I shouldn't do this in the #initialize of my root component? I think I
must get a new initialize every time I refresh the page - and so
register another notification?
So I'm wondering what the lifecycle of a WAComponent is? And where/how
I should initialize a singleton model? I've read the bits about
session's - but in my case I want multiple browsers to share the same
model (so each would be in its own session - so I don't think I want to
go that route?).
Do I lazy initialize the subscription along with the singleton model
(or is there a better way)? And when do I unsubscribe? I think I'm
missing the info about the component lifecycle - where should I look to
understand/read about that?
Tim
More information about the seaside
mailing list