tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/13149-mediators-stopped-working-all-of-a-suddenRobotlegs: Discussion 2015-10-28T15:51:48Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:26:59Z2015-08-25T14:26:59ZMediators stopped working all of a sudden<div><p>Add event listeners for added to stage and creation complete for
mainview, vgroup and PointOfSaleView. See (trace) if you are
attempting to add children to the vgroup while it is not on stage
yet.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:37:20Z2015-08-25T14:37:20ZMediators stopped working all of a sudden<div><p>I get in order</p>
<p>MainView added<br>
vGroup added<br>
PointOfSaleView added<br>
PointOfSaleView created<br>
PointOfSaleViewMediator initialized<br>
vGroup created<br>
MainView created<br>
MainViewMediator intialized</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:42:35Z2015-08-25T14:42:35ZMediators stopped working all of a sudden<div><p>Now, add PointOfSaleView from within your MainMediator (as you
had it in your code), but instead of view.addElement(new
PointOfSaleView());<br>
do: view.vGroup.addElement(new PointOfSaleView());</p>
<p>Also put a trace statement inside the method that creates and
adds the subviews, and see if it is called before vGroup is added
to the stage.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:43:03Z2015-08-25T14:43:17ZMediators stopped working all of a sudden<div><p>Things do break now with that, though the views still show up on
stage unlike before, but they are all wonky</p>
<p>EDIT: Before adding POS in the mediator</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:46:26Z2015-08-25T14:46:26ZMediators stopped working all of a sudden<div><p>I get</p>
<p>MainView added<br>
vGroup added<br>
vGroup created<br>
MainView created<br>
MainViewMediator intiialize<br>
MainViewMediator display view (method that creates
PointOfSaleView)<br>
PointOfSaleView added<br>
PointOfSaleView created<br>
PointOfSaleViewmediator initialize</p>
<p>And things are still wonky but are showing up on screen</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:48:05Z2015-08-25T14:48:05ZMediators stopped working all of a sudden<div><p>Wonky? The position/layout is not as expected or what?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:49:52Z2015-08-25T14:49:52ZMediators stopped working all of a sudden<div><p>The trace shows that when you add PointOfSaleView to the right
parent it gets added to the stage and its mediator is created. So,
from a robotlegs point of view everything is ok.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:50:13Z2015-08-25T14:50:13ZMediators stopped working all of a sudden<div><p>it looks like it's all added to the stage, but the widths and
heights of a lot of things seem like they must be set to 0. I can
see some components that have hardcoded widths/heights but ones
that use percentages seem to not be there (which i assuem in this
case means their widths/heights are 0)</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:50:53Z2015-08-25T14:50:53ZMediators stopped working all of a sudden<div><p>By the way, adding subviews to a view should be View's job. So,
after you make it work, you should transfer the logic from within
your main mediator to the main view. MainMediator should only pass
the necessary data to a MainView's API</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:52:12Z2015-08-25T16:58:24ZMediators stopped working all of a sudden<div><blockquote>
<p>it looks like it's all added to the stage, but the widths and
heights of a lot of things seem like they must be set to 0. I can
see some components that have hardcoded widths/heights but ones
that use percentages seem to not be there (which i assuem in this
case means their widths/heights are 0)</p>
</blockquote>
<p>That's a Flex problem. Can't say why it's happening. Maybe
instead of top/bottom etc, you should try x, y</p>
<p>[EDIT] mx.events.FlexEvent.CREATION_COMPLETE:<br>
Dispatched when the component has finished its construction,
property processing, measuring, layout, and drawing.<br>
At this point, depending on its visible property, the component is
not visible even though it has been drawn.</p>
<p>I'm mentioning this because it looks like some of your subviews
are not dispatching the event CREATION_COMPLETE, to which robotlegs
listens to in order to call mediator's initialize() method. This
might have something to do with the way you're setting the layout/
positions of the views. Try to fix the layout issue.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T14:57:43Z2015-08-25T14:57:43ZMediators stopped working all of a sudden<div><p>I think we solved the mediation problem, right? Can I do
anything else for you?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T15:00:14Z2015-08-25T15:00:14ZMediators stopped working all of a sudden<div><p>Ok. So.... how does this help with adding Child1/2 in the
previous structure to a VGroup? lol. I'm sorry for being dense.
Buuuuut none of this illustrates any points to me :/</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T15:08:58Z2015-08-25T15:08:58ZMediators stopped working all of a sudden<div><p>The point is, that you should add children to a View or a
subview (vgroup) first after they have a stage property. Also, that
you should add children to the right container.<br>
When views are added to the stage, as it was the case with
PointOfSaleView at last, their mediator is created and
initialized.<br>
The traces show that it worked well for PointOfSaleView, and if you
follow the same logic, it will work for any other subview. I don't
know where and how you add the child1 to 4, so I can't tell you how
to proceed.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T15:51:40Z2015-08-25T15:51:40ZMediators stopped working all of a sudden<div><p>Last question for today:</p>
<p>I actually wanted to ask it earlier, but I got carried away by
your messages.<br>
It seems like MainMediator is able to listen to the
DisplayViewEvent.DISPLAY_VIEW event, since the traces show the
PointOfSaleViewmediator initialize, but just for the sake of
completeness :</p>
<p>From where and when are you dispatching
DisplayViewEvent.DISPLAY_VIEW?</p>
<p>Is the MainMediator already initialized by the time you dispatch
the event?<br>
Are the mappings for the subviews completed by the time you
dispatch the event?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T15:58:56Z2015-08-25T15:58:56ZMediators stopped working all of a sudden<div><p>The AppMediator mediates my document class and listens for a
BootStrap complete event which then adds the MainView to the
WindowedApplication view. When the MainViewMediator is initialized
it tells MainView to add a LoginView to itself. When the user logs
in a LOGIN event is dispatched which that MainViewMediator catches
and tells it's view to remove the LoginView. I then have a
PostLoginCommand that runs also which dispatches the DisplayView
event at which point the MainViewMediator tells creates the
PointOfSaleView to add to MainView.</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T16:05:20Z2015-08-25T16:05:20ZMediators stopped working all of a sudden<div><p>Alright. In this case there is really nothing wrong with the
robotlegs part of things.<br>
I don't know what is still unclear to you or what is not working,
besides the Flex layout thing....</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-25T22:14:42Z2015-08-25T22:14:42ZMediators stopped working all of a sudden<div><p>The following links are about flex components and their
lifecycle. I thought they might help you figure out how to make
sure that the subcomponents fire the creation complete event,
which, as I said, is needed to trigger mediator's initialize()
method.</p>
<p><a href="http://help.adobe.com/en_US/flex/using/WS460ee381960520ad-2811830c121e9107ecb-7fff.html">
http://help.adobe.com/en_US/flex/using/WS460ee381960520ad-2811830c1...</a></p>
<p><a href="http://www.developmentarc.com/site/wp-content/uploads/pdfs/understanding_the_flex_3_lifecycle_v1.0.pdf">
http://www.developmentarc.com/site/wp-content/uploads/pdfs/understa...</a></p>
<p><a href="http://www.dlgsoftware.com/primers/Primer_on_Flex3_Component_Lifecycle.htm">
http://www.dlgsoftware.com/primers/Primer_on_Flex3_Component_Lifecy...</a></p>
<p><a href="http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf62b90-7ffc.html">
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c...</a></p>
<p>From the above article:<br>
"creationComplete Dispatched when the component, and all its child
components, and all their children, and so on, have been created,
laid out, and are visible.<br>
Flex dispatches the creationComplete event for a container when
those children that are initially required are fully processed and
drawn on the screen, including all required children of the
children, and so on. Create a listener for the
creationCompleteevent, for example, if you must have the
children’s dimensions and positions in your event handler. Do
not use the creationComplete event for actions that set layout
properties, as doing so results in excess processing time."</p>
<p>Also see if itemcreationpolicy set to imediate changes the
behaviour of your child- components.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-08-26T01:22:04Z2015-08-26T01:22:04ZMediators stopped working all of a sudden<div><p>Thanks for gathering the links!</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/377504382015-10-28T15:51:47Z2015-10-28T15:51:47ZMediators stopped working all of a sudden<div><p>I hope you found a solution for your Flex problem. Closing this
discussion for now. You can re-open it, if need be.</p></div>Ondina D.F.