[Seaside] Changing out components

Norbert Hartl norbert at hartl.name
Thu Oct 27 17:14:35 UTC 2011

Am 27.10.2011 um 19:10 schrieb Norbert Hartl:

> Am 27.10.2011 um 17:30 schrieb Agamemnon:
>> Lukas (or anyone else with an answer),
>> I hate to bother you too much but while I understand conceptually your
>> suggestions I'm having a hard time implementing it.  Here's what I have.
>> RootComponent>> initialize
>>       super initialize.
>> 	self menu ifNil: [self menu: MenuView new.].
>> 	self content ifNil: [self content: FamilyView new].
>> 	self subcomponent ifNil: [self subcomponent: FamilyEdit new].
>> 	self menu
>> 		viewFamily: [self content: FamilyView new];
>> 		viewMember: [self content: MemberView new].
>> MenuView>> renderContentOn: html
>> 	html div
>> 		class: 'menu-container';
>> 		with: [
>> 			html anchor
>> 				callback: [self viewFamily.];
>> 				with: 'Family'.
>> 			html break.
>> 			html anchor
>> 				callback: [self viewMember];
>> 				with: 'Member'].
>> This isn't working but I'm not sure how to change it.  I also can't find any
>> help online for passing blocks around in Smalltalk.  I obviously need the
>> "self" in the block to reference the "RootComponent" even when executing in
>> the "MenuView" but I'm not sure that is happening or how to get it to
>> happen.  I can get this to work easily by removing the MenuView altogether
>> and placing that code in the RootComponent but that doesn't seem to be a
>> very modular way of doing things.
> You need to execute the block. Try
> html anchor
> 	callback: [self viewFamily value ];
> 	with: 'Family'.
> Norbert

That was the short and quick answer. You can ease the setup by providing only one block. Try

self menu contentBlock: [:view| self content: view]

and then from the menu do

html anchor
	callback: [self contentBlock value: FamilyView new ];
	with: 'Family'.

That makes it easier to have a lot of menu entries.


More information about the seaside mailing list