Menu component - communicating with root component

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

Re: Re: Menu component - communicating with root component

Miguel Enrique Cobá Martínez
Squeaker wrote:
> Keith Hodges wrote:
>> Dear Ramon,
>>
>> I still dont get it.
>
> Me too. An example would be a great aid in understanding.  Are there any
> simple examples that exist?
>

You can check out the sample code from Philippe Marschall

Also initially in my app I used menus the way described here:

http://blog.leugim.com.mx/index.php/2008/01/03/seaside-menus/

but finally I realize that Announcements were the way to go.
The Announcements framework is a very powerful way to mantain loose
coupling in an application.


> _______________________________________________
> 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: Re: Menu component - communicating with root component

Boris Popov, DeepCove Labs (SNN)
I hate to keep beating this topic to death, but here's something mildly related,

http://yuiblog.com/blog/2008/04/22/caridy-decoupling/

Cheers,

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any
attachments.

Thank you.

> -----Original Message-----
> From: [hidden email] [mailto:seaside-
> [hidden email]] On Behalf Of Miguel Enrique Cobá
> Martínez
> Sent: Tuesday, April 22, 2008 10:27 PM
> To: Seaside - general discussion
> Subject: Re: [Seaside] Re: Menu component - communicating with root
> component
>
> Squeaker wrote:
> > Keith Hodges wrote:
> >> Dear Ramon,
> >>
> >> I still dont get it.
> >
> > Me too. An example would be a great aid in understanding.  Are there any
> > simple examples that exist?
> >
>
> You can check out the sample code from Philippe Marschall
>
> Also initially in my app I used menus the way described here:
>
> http://blog.leugim.com.mx/index.php/2008/01/03/seaside-menus/
>
> but finally I realize that Announcements were the way to go.
> The Announcements framework is a very powerful way to mantain loose
> coupling in an application.
>
>
> > _______________________________________________
> > 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
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Wandering Announcements - Design

keith1y
Further to the announcements debate.... here is a code design overview
for your considered appraisal.

"Wandering Announcements" inSeaside.

I am throwing some code together so there is some untested code
available in

Installer ss project: 'Jetsam'; install: 'Sea28WA'.

best regards

Keith

======

(This design is based upon Lukas' simple Announcements framework as a
starting point)

Whereas Announcements are often used with a centralized Announcer,
Wandering announcements may
look for someone to respond to their message in the given surroundings.
They may "bubble up" a component hierarchy, or interrogate siblings, or
decorations as they wish.

Each WAComponent in seaside is a node in this communications network.
Nodes function as potential announcers, and as a source of potential
routes for wandering announcements to follow.

Routing is provided by #ann* methods, which are private to the
Announcers for use by instances of WanderingAnnouncements, no one else
should call them.  e.g. #annParent #annSiblingsIn: [ :siblings | ....
].  #annChildrenIn: [ :children | .... ].

Unlike the original framework in which Announcements allow the Announcer
to figure out what to announce to whom, as much responsibility passed
over to each Announcement as is possible so that behaviour can be
overridden completely for different needs.

I.e. when handling an announcement we double back #announceTo: to the
announcement itself to give it complete control, over what it does
before or after informing dependants. It typically passes straight back
to the anouncers #dependantsAnnounce: for the default behavior. This
allows an Announcement to replace the behaviour of
Announcer-#dependantsAnnounce: altogether if it wants to.

Triggering example: (we always return the original announcer)

theAnnouncement := self announcer announce: (SomeAnnouncement param: arg1).

Subscriptions example:

self announcer on: SomeAnouncement do: [ :announcement | ...  ].
self announcer on: SomeAnouncement send: tellMe: to: anObject.

Normally, the announcer is passed as the argument to the
Block/MessageSend, however, each announcement implements #args, so it
can call a method that is not expecting an Announcement as the
parameter. This enables you to wire up objects that were not designed
with announcements in mind.

example trigger:

self announce: (HtmlUpdateAnnouncement on: html)

self announcer on: HtmlUpdateAnouncement send: #renderOn: to: anObject.

where:

HtmlUpdateAnnouncement-#args
^ Array with: html

=============
Wandering around
=============

Example... we have a list of items, and one of the items in the list has
just been clicked. It would like to inform the current selection, one of
its "siblings" that it is being de-selected. I say siblings, because it
doesnt really know where in the world it is.

The nature of this Seaside component world, is that there are some
objects that might be naturally considered to be siblings, so these are
automatically traversed by WALookupSideways. But we can also register
other objects/components which also respond to a sideways query, see below:

Client Code:

foundItem := ((aComponent announce:  (WALookupSideways selector:
#isSelected)) detect: [ :found | found isSelected ]) result.
foundItem ifNotNil: [ foundItem deselect ].

Walking through this example...  we give our announcement,
WALookupSideways, a selector to look out for. Every object in its
wandering that responds to the selector is passed into the detect block.
When the result of the detect block is true, wandering stops, and the
announcer is returned (remember we always return the announcer). We send
#result to the announcer to obtain the found item.

If there is an object that is not in the search path that would like to
participate, it can be registered like so.

aComponent announcer on: WALookupSideways do: [ :announcement |
announcement query: someObject ]


.....

hows that for starters..


Keith






















_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Wandering Announcements - Design - contd

keith1y
thoughts continued....

I had expressed the idea that a WAComponent was like an infant, unable
to articulate its needs, and unaware of its place in the world. In the
Wandering Announcements model we give each component the ability to
specify what it does know about the world. That is all it is doing, it
is just saying, what the world around it is like, what is above, below
to the left and to the right.

It is up to wandering announcements to make use of these relationships
for routing events. Child components do not explicitly know anything
about their parents. But they do know that they may have a parent, or a
brother, and they can shout, oi Dad, oi Bro', and get a response.

Components implement:

#annParent

#annChildrenIn: block

and hence:

#annSiblingsIn: block

Wandering announcements use these as implicit relationships over which
to wander. Note however that these published relationships need not be
related to the actual component hierarchy.

A chess board, could publish each of its 64 squares as annChildrenIn:
even though in actual fact, it is implemented by 8 x
WAChessBoardRowComponents. This would allow each of the squares to
announce to all 63 of its siblings, even though in the actual component
hierarchy each square only has 7 direct siblings.

There is nothing stopping additional objects that are not in the right
place at the right time to be included as a sibling, they are simply
subscribed to the announcements meant for siblings.

There is nothing stopping more spatial relationships being defined, such
as..

#annBoardSquares

or

#annItemsToMyLeft

or

#annTrainTrackNextPiece

A chess board, has one implementation, a monopoly board has an entirely
different implementation. However a "white knight" could be equally at
home on either and can do things such as.

self announce: (HighlightValidMoves for: self)

I think this preserves the principles that Children dont know explicitly
about their parents, but now they have permission to ask questions of
their surroundings.

ok, now to test this all out!

Keith





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