[Seaside] Re: Menu component - communicating with root component

Ramon Leon ramon.leon at allresnet.com
Sun Apr 20 06:49:47 UTC 2008


> That's the point of announcements, they are an instance of a 
> class and carry whatever data you desire. If you need the 
> instance of the menu item in the announcement then put it there.
> 
> I'd be inclined to then put the behavior you want on the 
> menu items themselves and the receiver of the announcement 
> just asks the announcement item to process the necessary 
> data. The menu item doesn't know about the data per se, it 
> just holds the behavior to apply to the data when the 
> behavior method gets invoked with the data as an argument.
> 
> HTH
> Steve

Exactly the point, rather than just fire some generic event or symbol, you
reify the message, the announcement as a full blown object able to carry
both information and behavior if necessary with them.  You could announce a
block with a callback so the parent doesn't even know what the child is
doing.  

Say I keep a parent component broken up into children such as header,
footer, menu, and body and I want the currently loaded X to be able to be
reloaded by an even triggered by Y.  The menu to change the body, the body
to change the navigation, the navigation to change the body and header at
the same time, i.e. multiple other parties interested in the event, etc.  I
could just design an event that when fired, gives me the component I want to
talk to, as if it were a phone call where the interested party would pick
up...

self announce: (ReloadBody with: [:body | body call: (SomeOtherReport model:
self model) ]).

And any component anywhere in the system could fire off that same line and
have the correct "body" component answer and react appropriately without
coupling them together in some hard coded parent/child relationship.

Ramon Leon
http://onsmalltalk.com



More information about the seaside mailing list