problem with mediator and service.

Seungtack Baek's Avatar

Seungtack Baek

24 Jun, 2010 08:58 PM

Hello, I am trying to build a simple app that consists of a button (in fl.controls package, I imported those by exporting swc in CS5) and a list (in fl.controls package, same senario).

There are two problems with my app: 1. The button gets mediated (consol outputs "button mediated"), but list does not. 2. Also, in, the instance of AccessDataService, service, which I injected, is causing Error #1009, being null.

The attached files are my source files.

  1. Support Staff 1 Posted by Shaun Smith on 24 Jun, 2010 09:21 PM

    Shaun Smith's Avatar

    Try changing the order of things in your context startup:

    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);

    Notice that the ApplicationMediator mapping happens right at the end.

    When you map a mediator to the contextView that mediator gets created immediately, so this line:

    mediatorMap.mapView(RSSInfo, ApplicationMediator);

    was causing an instance of ApplicationMediator to be created immediately - which, in your case, was too soon (before the ListViewMediator and IAccessDataService were mapped).

    Hope that helps!

  2. 2 Posted by Seungtack Baek on 25 Jun, 2010 04:04 PM

    Seungtack Baek's Avatar

    THANKS A LOT! that fixed the ListView Issue.

    However, it keeps saying that "service" in the is null.

    How so?

  3. Support Staff 3 Posted by Shaun Smith on 25 Jun, 2010 05:29 PM

    Shaun Smith's Avatar


    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:

    public class AccessDataCommand extends Command
        public var service:IAccessDataService;
        override public function execute():void
  4. Stray closed this discussion on 16 Feb, 2011 09:05 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac