I've got a RootComponent. It contains two embedded components; aMenuComponent and aContentComponent. I need a callback from aMenuComponent to alter what the component in aContentComponent is. How do I do this without coupling too tightly? This seems like a very common setup so surely it can be done.
Thanks, Andrew |
I use the announcements framework On Oct 26, 2011 1:24 PM, "Agamemnon" <[hidden email]> wrote: _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Or simpler, the outer component configures the inner component with a
block that is called when the components need to change. Lukas On 26 October 2011 19:53, Larry White <[hidden email]> wrote: > I use the announcements framework > > On Oct 26, 2011 1:24 PM, "Agamemnon" <[hidden email]> wrote: >> >> I've got a RootComponent. It contains two embedded components; >> aMenuComponent and aContentComponent. I need a callback from >> aMenuComponent >> to alter what the component in aContentComponent is. How do I do this >> without coupling too tightly? This seems like a very common setup so >> surely >> it can be done. >> >> Thanks, >> >> Andrew >> >> -- >> View this message in context: >> http://forum.world.st/Changing-out-components-tp3941427p3941427.html >> Sent from the Seaside General mailing list archive at Nabble.com. >> _______________________________________________ >> seaside mailing list >> [hidden email] >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > -- Lukas Renggli www.lukas-renggli.ch _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Thanks guys. I'm pretty new to both Smalltalk and Seaside so those suggestions really helped.
|
On Wed, Oct 26, 2011 at 3:45 PM, Agamemnon <[hidden email]> wrote: Thanks guys. I'm pretty new to both Smalltalk and Seaside so those If you're really new, you may not know that Lukas's suggestion is much better than mine. I would actually only recommend using the announcement framework if one component was not a direct child of the other (if peers needed to communicate for example). The announcement framework is very powerful but less straightforward.
As a general rule, always listen to Lukas. ;) cheers -- _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Agamemnon
Hello,
So, I've been saving images in Pharo, with Seaside, so that I could bring them back up again. Now, when I try to bring up one of the images, I see all of the windows as they last appeared, for about three seconds, before they all disappear. I can't find any of the project code I have loaded, it is like having a base Pharo image. I'm running Pharo on my Amazon EC2 instance, which was working fine last week. I changed the GemStone.sh file to point to one of the new images. Has anybody see anything like this happen before? I'm stumped. Regards, Larry _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Lukas Renggli
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. Andrew |
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 _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
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. Norbert _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by NorbertHartl
Norbert,
You are brilliant. Thanks. It works perfectly now. Is there any way to have a value passed into the block? I know that the do:[] message on the Collections object takes each item in the Collection as a value. [:anItem | anItem doesSomething.] How would this work here? Andrew |
Browse BlockClosure.
Check out http://pharobyexample.org/ (page 55). It'll look something like: | function | function := [:param1 :param2 | ... ]. function value: value1 value: value2: RS > Date: Thu, 27 Oct 2011 12:34:17 -0700 > From: [hidden email] > To: [hidden email] > Subject: [Seaside] Re: Changing out components > > Norbert, > > You are brilliant. Thanks. It works perfectly now. Is there any way to > have a value passed into the block? I know that the do:[] message on the > Collections object takes each item in the Collection as a value. [:anItem | > anItem doesSomething.] How would this work here? > > Andrew > > -- > View this message in context: http://forum.world.st/Changing-out-components-tp3941427p3945760.html > Sent from the Seaside General mailing list archive at Nabble.com. > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Agamemnon
His second example showed the way...
self menu contentBlock: [:view| self content: view] and then from the menu do html anchor callback: [self contentBlock value: FamilyView new ]; with: 'Family'. value: is the key On 10/27/11 3:34 PM, Agamemnon wrote: Norbert, You are brilliant. Thanks. It works perfectly now. Is there any way to have a value passed into the block? I know that the do:[] message on the Collections object takes each item in the Collection as a value. [:anItem | anItem doesSomething.] How would this work here? Andrew -- View this message in context: http://forum.world.st/Changing-out-components-tp3941427p3945760.html Sent from the Seaside General mailing list archive at Nabble.com. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |