tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/159-view-states-handlingRobotlegs: Discussion 2018-10-18T16:35:12Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/16639012010-05-12T09:25:11Z2010-05-12T09:25:11ZView states handling<div><p>Indeed, mapping multiple mediators to a single view class is not
supported in the current version of Robotlegs.</p>
<p>One solution might be to create a base Mediator class that you
extend. This is a little more complicated than usual due to the
injection of the view component into the mediator - the base
mediator will specify injection of a certain view type, but the
derived mediator classes will need access to different view types.
The solution here is to create a getter that casts the
viewComponent property into the correct type for each mediator
(instead of specifying the the view as an injection point).</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/16639012010-05-24T07:10:31Z2010-05-24T20:41:52ZView states handling<div><p>I've kind of got this working. However my base mediator and the
derived mediators both need to access the view - so would this:</p>
<p>"The solution here is to create a getter that casts the
viewComponent property into the correct type for each mediator
(instead of specifying the the view as an injection point)."</p>
<p>Still apply? The only way I can get it to work is to have</p>
<pre>
<code>public function get view(): *
{
return viewComponent;
}</code>
</pre>
<p>Which doesn't really follow your advice.<br></p></div>Altag:robotlegs.tenderapp.com,2009-10-18:Comment/16639012010-05-24T13:59:07Z2010-05-24T13:59:07ZView states handling<div><p>Sorry, that wasn't very clear. What I meant was that you'd
create a specific getter for each mediator:</p>
<pre>
// In the base mediator (if needed)
public function get baseView():BaseView
{
return viewComponent as BaseView;
}
// In derived mediator A
public function get specificViewA():SpecificViewA
{
return viewComponent as SpecificViewA;
}
// In derived mediator B
public function get specificViewB():SpecificViewB
{
return viewComponent as SpecificViewB;
}
</pre>
<p>That way you have a correctly casted view component reference
for each mediator.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/16639012010-05-24T20:30:24Z2010-05-24T20:30:24ZView states handling<div><p>Thanks!<br></p>
<p>Makes sense now.</p></div>Al