Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Problems sending notification  (Read 7872 times)
sinosoidal
Jr. Member
**
Posts: 15


View Profile Email
« on: October 14, 2008, 07:49:58 »

Hi,

I'm giving my first steps in PureMVC.

I'have already done a login system and now i want to use the framework to manage visual state as well.

For that i have tried to follow the slaker example.

The thing is that after the access is granted, in my access proxie I invoke an AccessGranted notification which will do the following

public class AccessGrantedCommand extends SimpleCommand {
      
      override public function execute (note:INotification) : void {
         mx.controls.Alert.show("im here1");
         
         var applicationMediator:ApplicationMediator;
         
         mx.controls.Alert.show("NOTIFICATION SEN1");
         
         applicationMediator = facade.retrieveMediator("ApplicationMediator") as ApplicationMediator;
         
         mx.controls.Alert.show("NOTIFICATION SEN2");
         
         applicationMediator.sendNotification(ApplicationFacade.MAINDISPLAY_MODE);
         
         mx.controls.Alert.show("NOTIFICATION SEN3");
      }
   }

But no notifitcation is being released. I have placed some alerts to see what is happening and the third alert is not called.

Can anybody help me here?

Thanks,

Nuno
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: October 14, 2008, 08:13:54 »

You don't need to retrieve the ApplicationMediator to send a notification, in fact it won't work as you have it. It is the facade that sends notifications. The following will do:
:
public class AccessGrantedCommand extends SimpleCommand {
     
      override public function execute (note:INotification) : void {
         mx.controls.Alert.show("im here1");
         mx.controls.Alert.show("NOTIFICATION SEN1");
         
         facade.sendNotification(ApplicationFacade.MAINDISPLAY_MODE);
      }
   }
I'd also recommend putting your third alert in the listener for MAINDISPLAY_MODE to check if the note is being sent, rather than in the command. What you had only says the command completed, not that the notification sent.
« Last Edit: October 14, 2008, 08:15:40 by jasonmac » Logged
sinosoidal
Jr. Member
**
Posts: 15


View Profile Email
« Reply #2 on: October 14, 2008, 08:40:04 »

Hi,

Thanks for the reply.

It is not working. Nothing happens.

I have an Alert in the ApplicationMediator handleNotification method and nothing happens there.

What can be wrong?

This is my ApplicationMediator:

:
public class ApplicationMediator extends Mediator
    {
        public static const NAME:String = 'ApplicationMediator';
       
        public function ApplicationMediator( viewComponent:Object )
        {
            super( NAME, viewComponent );   
        }
       
        override public function onRegister():void
        {
            facade.registerMediator(new MainDisplayMediator(app.mainDisplay));
        }
       
        override public function listNotificationInterests():Array
        {
            return [ApplicationFacade.LOGIN_MODE,
            ApplicationFacade.MAINDISPLAY_MODE]
        }
       
override public function handleNotification(note:INotification):void
{
mx.controls.Alert.show("im here2");

switch (note.getName())
{
case ApplicationFacade.LOGIN_MODE:
app.currentViewSelector = Main.LOGIN;
break;
case ApplicationFacade.MAINDISPLAY_MODE:
app.currentViewSelector = Main.MAINDISPLAY;
break;
           }
       }

        protected function get app():Main
        {
            return viewComponent as Main;
        }

Thanks,

Best regards,

Nuno Santos
Logged
sinosoidal
Jr. Member
**
Posts: 15


View Profile Email
« Reply #3 on: October 14, 2008, 08:50:24 »

Hi,

Its working!

I found a bug.

Thanks,

Nuno
Logged
Pages: [1]
Print