tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/300-lazy-mediation-of-viewstackRobotlegs: Discussion 2018-10-18T16:35:25Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/66223152011-04-13T19:34:24Z2011-04-13T19:34:24ZLazy Mediation of ViewStack<div><p>Hi, are you trying to access the "label" in the constructor of
ViewB?</p></div>krasimirtag:robotlegs.tenderapp.com,2009-10-18:Comment/66223152011-04-13T19:38:28Z2011-04-13T19:38:29ZLazy Mediation of ViewStack<div><p>i override the "onRegister" in my mediators, and have a method
called "initLabel". that method tries to access the label via the
vew. Just everytime it tries, the view associated with the mediator
is null.</p></div>Penuttag:robotlegs.tenderapp.com,2009-10-18:Comment/66223152011-04-13T19:40:25Z2011-04-13T19:40:25ZLazy Mediation of ViewStack<div><p>So you call initLabel in your onRegister method.</p></div>krasimirtag:robotlegs.tenderapp.com,2009-10-18:Comment/66223152011-04-13T19:44:41Z2011-04-13T19:44:43ZLazy Mediation of ViewStack<div><p>Yes, that is what is happening. I'm only using that to test the
changing of the viewstack.</p></div>Penuttag:robotlegs.tenderapp.com,2009-10-18:Comment/66223152011-04-13T19:46:37Z2011-04-13T19:46:37ZLazy Mediation of ViewStack<div><p>Is it possible to isolate only this part of the application and
attach it here. So we can check ;)</p></div>krasimirtag:robotlegs.tenderapp.com,2009-10-18:Comment/66223152011-04-13T19:49:19Z2011-04-13T19:49:19ZLazy Mediation of ViewStack<div><p>i wish it were possible, however its not. I can build a similar
setup when I'm not at my office to post.</p></div>Penuttag:robotlegs.tenderapp.com,2009-10-18:Comment/66223152011-04-13T20:06:58Z2011-04-13T20:06:58ZLazy Mediation of ViewStack<div><p>I most of the cases isolating the problem in a small app helps a
lot. Maybe the problem is not in the view or in the mediator at
all.</p></div>krasimirtag:robotlegs.tenderapp.com,2009-10-18:Comment/66223152011-04-20T23:57:25Z2011-05-02T13:29:33ZLazy Mediation of ViewStack<div><p>The initialization is a little weird when creationPolicy is
auto. <a href=
"http://www.developria.com/2009/11/handling-delayed-instantiation.html">
http://www.developria.com/2009/11/handling-delayed-instantiation.html</a></p>
<p>Personally, I would not have a Mediator reaching into the View
that way--the View should be data driven and the Mediator should
manipulate its <em>data</em> if necessary. So you might have a
thingName property that your View exposes and the label binds to,
and your Mediator would set thingName based on whatever you've told
it about the application's state.</p>
<p>If you absolutely HAVE to do this, you can do one of several
things</p>
<ol>
<li>
<p>Listen for the initialize event, which shouldn't happen before
processedDescriptors is true. Once this has fired, your label
should exist.</p>
</li>
<li>
<p>Use your Mediator to set up a Context on the View, which will
map a Mediator to the Label when it hits the stage</p>
</li>
<li>
<p>Make the label a "marker" subclass, and give it its own Mediator
or give it a public property that you can [Inject] into by adding
the Label's Class to the ViewMap.</p>
</li>
</ol></div>Amy Blankenship