tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/115-problem-with-mediator-and-serviceRobotlegs: Discussion 2013-04-28T10:01:11Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/20709742010-06-24T21:21:21Z2010-06-24T21:21:21Zproblem with mediator and service.<div><p>Try changing the order of things in your context startup:</p>
<pre>
override public function startup():void
{
commandMap.mapEvent(AccessDataEvent.DATA_REQUESTED, AccessDataCommand, AccessDataEvent);
injector.mapSingletonOf(IAccessDataService, AccessDataService);
mediatorMap.mapView(ButtonView, ButtonViewMediator);
mediatorMap.mapView(ListView, ListViewMediator);
mediatorMap.mapView(RSSInfo, ApplicationMediator);
super.startup();
}
</pre>
<p>Notice that the ApplicationMediator mapping happens right at the
end.</p>
<p>When you map a mediator to the contextView that mediator gets
created immediately, so this line:</p>
<p><code>mediatorMap.mapView(RSSInfo,
ApplicationMediator);</code></p>
<p>was causing an instance of ApplicationMediator to be created
immediately - which, in your case, was too soon (before the
ListViewMediator and IAccessDataService were mapped).</p>
<p>Hope that helps!</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/20709742010-06-25T16:04:25Z2010-06-25T16:04:27Zproblem with mediator and service.<div><p>THANKS A LOT! that fixed the ListView Issue.</p>
<p>However, it keeps saying that "service" in the
AccessDataCommand.as is null.</p>
<p>How so?</p></div>Seungtack Baektag:robotlegs.tenderapp.com,2009-10-18:Comment/20709742010-06-25T17:29:15Z2010-06-25T17:29:15Zproblem with mediator and service.<div><p>Hi,</p>
<p>You are trying to access the property in the AccessDataCommand's
constructor - that is too soon, the property will not have been
injected yet. You should move that code into the execute() method,
like so:</p>
<pre>
public class AccessDataCommand extends Command
{
[Inject]
public var service:IAccessDataService;
override public function execute():void
{
service.loadData();
}
}
</pre></div>Shaun Smith