WAComponent subclass: #SAChild instanceVariableNames: 'number' classVariableNames: '' poolDictionaries: '' category: 'SeasideAnnouncementDemo'! !SAChild commentStamp: 'rjl 4/24/2007 10:07' prior: 0! I am a child component, I know nothing, but I fire the RemoveChild announcement to a session level announcer, I hope someone is listening.! !SAChild methodsFor: 'rendering' stamp: 'rjl 4/24/2007 10:07'! number "I am unique, this is my number" ^ number ifNil: [number := 100 atRandom]! ! !SAChild methodsFor: 'rendering' stamp: 'rjl 4/24/2007 10:08'! remove "tell the announcer I can be removed" self session announce: (SARemoveChild child: self)! ! !SAChild methodsFor: 'rendering' stamp: 'rjl 4/24/2007 09:52'! renderContentOn: html html render: self number. html anchor on: #remove of: self. html break.! ! WAComponent subclass: #SAParent instanceVariableNames: 'children' classVariableNames: '' poolDictionaries: '' category: 'SeasideAnnouncementDemo'! !SAParent commentStamp: 'rjl 4/24/2007 10:07' prior: 0! I am a parent component, I have children who do not know me, but I have registered with a session level announcer who will tell me when my children want to be removed.! !SAParent methodsFor: 'accessing' stamp: 'rjl 4/24/2007 10:08'! buildChildren "build some children for demo" ^ {SAChild new. SAChild new. SAChild new. SAChild new} asOrderedCollection! ! !SAParent methodsFor: 'accessing' stamp: 'rjl 4/24/2007 10:00'! children ^ children ifNil: [children := self buildChildren ]! ! !SAParent methodsFor: 'actions' stamp: 'rjl 4/24/2007 10:09'! removeChild: anEvent "the announcer is sending me this announcement, a child can be removed, the announcement itself is my own object, so I know the child that needs to be removed is on it." self children remove: anEvent child! ! !SAParent methodsFor: 'initialization' stamp: 'rjl 4/24/2007 10:10'! initialize super initialize. "Whenever this announcement is sent, tell the announcer to fire this method on me passing in the instance of this class I'm expecting'" self session on: SARemoveChild send: #removeChild: to: self! ! !SAParent methodsFor: 'rendering' stamp: 'rjl 4/24/2007 10:01'! renderContentOn: html html heading: 'Announcement demo, press remove to fire event' level: 1. self children do: [:each | html render: each]! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! SAParent class instanceVariableNames: ''! !SAParent class methodsFor: 'initialization' stamp: 'rjl 4/24/2007 09:54'! initialize "self initialize" | app | app := self registerAsApplication: #notificationTest. app preferenceAt: #sessionClass put: SASession! ! Announcement subclass: #SARemoveChild instanceVariableNames: 'child' classVariableNames: '' poolDictionaries: '' category: 'SeasideAnnouncementDemo'! !SARemoveChild commentStamp: 'rjl 4/24/2007 10:11' prior: 0! I am a custom announcement, I am just like an event, but with a longer name so as not to be confused with the existing old event system. I carry information about me that subscribers might find useful, like the child I want removed.! !SARemoveChild methodsFor: 'accessing' stamp: 'rjl 4/24/2007 09:48'! child ^child! ! !SARemoveChild methodsFor: 'accessing' stamp: 'rjl 4/24/2007 09:48'! child: anObject child := anObject! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! SARemoveChild class instanceVariableNames: ''! !SARemoveChild class methodsFor: 'instance creation' stamp: 'rjl 4/24/2007 09:49'! child: aChild ^self new child: aChild; yourself! ! WASession subclass: #SASession instanceVariableNames: 'announcer' classVariableNames: '' poolDictionaries: '' category: 'SeasideAnnouncementDemo'! !SASession commentStamp: 'rjl 4/24/2007 10:12' prior: 0! I am a Seaside session, and I carry an announcer and wrap him so he is globablly accessable from within this application, components within this app can treat me as the announcer.! ]style[(67 112)cred;,f3! !SASession methodsFor: 'accessing' stamp: 'rjl 4/24/2007 09:48'! announcer ^ announcer ifNil:[announcer := Announcer new]! ! !SASession methodsFor: 'actions' stamp: 'rjl 4/24/2007 09:55'! announce: anEvent self announcer announce: anEvent! ! !SASession methodsFor: 'actions' stamp: 'rjl 4/24/2007 09:58'! on: anEvent do: aBlock self announcer on: anEvent do: aBlock! ! !SASession methodsFor: 'actions' stamp: 'rjl 4/24/2007 10:01'! on: anEvent send: aSelector to: anObject self announcer on: anEvent send: aSelector to: anObject ! ! SAParent initialize!