How to access the parent of a component?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to access the parent of a component?

bahman
Hi all,

I have a big component consisting of smaller ones.

<code>

WAComponent subclass: #BigComponent
        instanceVariableNames: 'smallComponent placeHolder'
        classVariableNames: ''
        poolDictionaries: ''
        category: ''

WAComponent>>#children
        ^ Array with: self smallComponent with: self placeHolder.

</code>

Now I'm trying to change `placeHolder' from an `anchor' callback in
`smallComponent'.

<code>

SmallComponent>>#renderContentOn: h
        h anchor
                callback: [
                    self parent placeHolder: SomeOtherComponent new ];
                with: 'Some other component' ].

</code>

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?

TIA,

--
Bahman Movaqar  (http://BahmanM.com)
ERP Evaluation, Implementation, Deployment Consultant
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: How to access the parent of a component?

Robert Sirois
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".

RS

> Date: Sun, 2 Jun 2013 05:19:48 +0430

> From: [hidden email]
> To: [hidden email]
> Subject: [Seaside] How to access the parent of a component?
>
> Hi all,
>
> I have a big component consisting of smaller ones.
>
> <code>
>
> WAComponent subclass: #BigComponent
> instanceVariableNames: 'smallComponent placeHolder'
> classVariableNames: ''
> poolDictionaries: ''
> category: ''
>
> WAComponent>>#children
> ^ Array with: self smallComponent with: self placeHolder.
>
> </code>
>
> Now I'm trying to change `placeHolder' from an `anchor' callback in
> `smallComponent'.
>
> <code>
>
> SmallComponent>>#renderContentOn: h
> h anchor
> callback: [
> self parent placeHolder: SomeOtherComponent new ];
> with: 'Some other component' ].
>
> </code>
>
> 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?
>
> TIA,
>
> --
> Bahman Movaqar (http://BahmanM.com)
> ERP Evaluation, Implementation, Deployment Consultant
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: How to access the parent of a component?

bahman
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.

> RS
>
>> Date: Sun, 2 Jun 2013 05:19:48 +0430
>> From: [hidden email]
>> To: [hidden email]
>> Subject: [Seaside] How to access the parent of a component?
>>
>> Hi all,
>>
>> I have a big component consisting of smaller ones.
>>
>> <code>
>>
>> WAComponent subclass: #BigComponent
>> instanceVariableNames: 'smallComponent placeHolder'
>> classVariableNames: ''
>> poolDictionaries: ''
>> category: ''
>>
>> WAComponent>>#children
>> ^ Array with: self smallComponent with: self placeHolder.
>>
>> </code>
>>
>> Now I'm trying to change `placeHolder' from an `anchor' callback in
>> `smallComponent'.
>>
>> <code>
>>
>> SmallComponent>>#renderContentOn: h
>> h anchor
>> callback: [
>> self parent placeHolder: SomeOtherComponent new ];
>> with: 'Some other component' ].
>>
>> </code>
>>
>> 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
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How to access the parent of a component?

bahman
On 2013-06-02 09:45, Robert Sirois wrote:
> I suppose it depends on if you're going to use the call/answer method or
> a WATask or something. I'm not very schooled in the ways of Seaside
> architecture, but I hope that helps in the meantime.
>
> I always just use Announcements because they're clean, organized, and
> they allow for a bit more of a remote approach I suppose.

Thanks!  I just put "Announcements" on my TODO list.  However, for the
time being, I'll stick with the dirty approach to keep it simple :-)

>> Date: Sun, 2 Jun 2013 07:30:58 +0430
>> From: [hidden email]
>> To: [hidden email]
>> CC: [hidden email]
>> Subject: Re: [Seaside] How to access the parent of a component?
>>
>> 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.
>>
>> > RS
>> >
>> >> Date: Sun, 2 Jun 2013 05:19:48 +0430
>> >> From: [hidden email]
>> >> To: [hidden email]
>> >> Subject: [Seaside] How to access the parent of a component?
>> >>
>> >> Hi all,
>> >>
>> >> I have a big component consisting of smaller ones.
>> >>
>> >> <code>
>> >>
>> >> WAComponent subclass: #BigComponent
>> >> instanceVariableNames: 'smallComponent placeHolder'
>> >> classVariableNames: ''
>> >> poolDictionaries: ''
>> >> category: ''
>> >>
>> >> WAComponent>>#children
>> >> ^ Array with: self smallComponent with: self placeHolder.
>> >>
>> >> </code>
>> >>
>> >> Now I'm trying to change `placeHolder' from an `anchor' callback in
>> >> `smallComponent'.
>> >>
>> >> <code>
>> >>
>> >> SmallComponent>>#renderContentOn: h
>> >> h anchor
>> >> callback: [
>> >> self parent placeHolder: SomeOtherComponent new ];
>> >> with: 'Some other component' ].
>> >>
>> >> </code>
>> >>
>> >> 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
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How to access the parent of a component?

Philippe Marschall
On Sun, Jun 2, 2013 at 8:47 AM, Bahman Movaqar <[hidden email]> wrote:

> On 2013-06-02 09:45, Robert Sirois wrote:
>> I suppose it depends on if you're going to use the call/answer method or
>> a WATask or something. I'm not very schooled in the ways of Seaside
>> architecture, but I hope that helps in the meantime.
>>
>> I always just use Announcements because they're clean, organized, and
>> they allow for a bit more of a remote approach I suppose.
>
> Thanks!  I just put "Announcements" on my TODO list.  However, for the
> time being, I'll stick with the dirty approach to keep it simple :-)

Here's an article explaining it

 [1] http://onsmalltalk.com/maintaining-loose-coupling-in-seaside-components

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside