tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/293-events-from-nested-components-confirmationsuggestionsRobotlegs: Discussion 2018-10-18T16:35:25Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/64792992011-04-07T17:31:07Z2011-04-07T17:31:07ZEvents from nested components (Confirmation/Suggestions)<div><p>I've decided to use custom events within the children of the
mediated view. To me, that appears dirty, but I have no other
suggestions or idea. I'm going to keep it open just incase someone
comes up with an idea. Thanks.</p></div>samac1068tag:robotlegs.tenderapp.com,2009-10-18:Comment/64792992011-04-08T07:55:27Z2011-04-08T07:56:11ZEvents from nested components (Confirmation/Suggestions)<div><p>Mediators that are generated when a view is created are not
referred to as popups. Popups are for instance Alert instances and
they too can be mediated, but slightly differently than a "normal"
component, that's what the link you gave describes.<br>
Whenever a component is added to the stage that is mapped to be
mediated it's mediator will be instantiated automatically, that's
normal procedure and has little to do with it being a popup or
not.<br>
Now, on to your question. Basically you can mediate any display
object that gets added to the stage. In reality it's a bit harder
sometimes because you don't always have full control/access to a
component's children, so in those cases you'll mediate the entire
component instead of the children.<br>
It all depends on what you want to do actually. If I understand it
correctly from your diagram, the lowest level display objects
('grid') dispatch events that need to be relayed to the
framework??<br>
Then you have two choices, either you mediate each grid separately,
or you mediate their container. From your diagram I can't deduce
what the container would be. For instance what are those squares
with the numbers in them? But let's say nr 2 is a canvas that
contains those four grids, then you could let nr 2 listen to the
events of all the grid objects and pass them to its mediator.</p>
<p>And using custom events in a view's children is never a bad
idea, on the contrary I'd advise using custom events as much as
possible.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/64792992011-04-08T13:37:36Z2011-04-08T13:37:37ZEvents from nested components (Confirmation/Suggestions)<div><p>The beauty of how RobotLegs works is that you don't need access
to the children. If you let the mediators be created automatically
by the Context, then they will automatically be attached to the
renderer (for example) when it hits the display list, no matter how
deeply nested it is.</p>
<p>If you need to know about the data in the renderer to do
whatever you're trying to do with your mediator, you need to add a
view listener on its dataChange event in the onRegister() handler
so that you can update the Mediator's state in line with the
data.</p>
<p>If you <em>don't</em> care about the data, you probably don't
need to mediate at the renderer level anyway, because the link
event bubbles, and you can handle it at a higher level.</p>
<p>HTH;</p>
<p>Amy</p></div>Amy