[Seaside] How to access the parent of a component?
Bahman at BahmanM.com
Sun Jun 2 03:00:58 UTC 2013
On 2013-06-02 07:25, Robert Sirois wrote:
> Just because the "smallComponent" is included in the children of your
> "bigComponent" doesn't make the "bigComponent" the parent of
> "smallComponent" architecturally. That statement sounds confusing, I
> know. Including components in children does not cause those children to
> have references (instance variables, for example) to the component that
> returns them as children (which you're expecting to be parent). What
> you'll have to do is create an instance variable on "smallComponent" and
> set a reference to "bigComponent".
Thanks for the hint! I thought so too but then I wondered is that the
best way? I mean putting a reference to the so-called parent inside the
child looks a bit suspicious, right?
I'll proceed with the approach you suggested but please let me know if
there's some cleaner way.
>> Date: Sun, 2 Jun 2013 05:19:48 +0430
>> From: Bahman at BahmanM.com
>> To: seaside at lists.squeakfoundation.org
>> Subject: [Seaside] How to access the parent of a component?
>> Hi all,
>> I have a big component consisting of smaller ones.
>> WAComponent subclass: #BigComponent
>> instanceVariableNames: 'smallComponent placeHolder'
>> classVariableNames: ''
>> poolDictionaries: ''
>> category: ''
>> ^ Array with: self smallComponent with: self placeHolder.
>> Now I'm trying to change `placeHolder' from an `anchor' callback in
>> SmallComponent>>#renderContentOn: h
>> h anchor
>> callback: [
>> self parent placeHolder: SomeOtherComponent new ];
>> with: 'Some other component' ].
>> But I get this exception: `SmallComponent(Object)>>doesNotUnderstand:
>> #parent' which, I believe, says that I cannot access the container
>> component like this.
>> What is the best way to do this (access the container component)? Is it
>> possible at all?
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation, Deployment Consultant
More information about the seaside