PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: isragaytan on May 14, 2009, 10:16:06



Title: Mediator dont listen for CUSTOM Events
Post by: isragaytan on May 14, 2009, 10:16:06
Hi Again   ;D

Now the issue of the day is..

My Mediator dont listen for CUSTOM events....

Here is the scenario:

I have my view that dispatch an Event like this:

private function buscarPersonaRfc():void{
            
            var evtObj:BusquedaRFCEvent=new BusquedaRFCEvent("BusquedaRFCEvent",txtRfc.text);

            dispatchEvent(evtObj);
            
            
         }

and in my Mediator i have..

override public function onRegister():void{
         
         //Referencia a la aplicacion principal
         APPNAME=BusquedaPersonas.NAME;
         
         buscarPersonaProxy=facade.retrieveProxy("BuscarPersonaProxy") as BuscarPersonaProxy;
         
         buscarPersona.addEventListener("BusquedaRFCEvent",PBuscarPersona);
      }


When i click on the propper button it doesnt happen anything!...

the strange thing its that if i dispatch another event (no custom event), an event like..
private function buscarPersonaRfc():void{
            
            dispatchEvent(new Event("buscaPersonaNombre",true));
            
            
         }


and in my mediator i have..

override public function onRegister():void{
         
         //Referencia a la aplicacion principal
         APPNAME=BusquedaPersonas.NAME;
         
         buscarPersonaProxy=facade.retrieveProxy("BuscarPersonaProxy") as BuscarPersonaProxy;
         
         buscarPersona.addEventListener("buscaPersonaNombre",PBuscarPersona);
      }

IT WORKS!!!....how am i missing. Do i have again register all the mediators in the ApplicationMediator???

Any guidelines?? Thanks to all, i am starting with this framework :D sorry for all my quiestions :D









Title: Re: Mediator dont listen for CUSTOM Events
Post by: puremvc on May 15, 2009, 07:52:33
Is bubbles = true for your event? Notice that when you create a new standard event, you set the bubbles parameter to true. If a child of the view dispatches the event then only the view has the opportunity to handle it. The mediator listening to that view will never be notified. If the event bubbles, then it will make it to the mediator.

-=Cliff>


Title: Re: Mediator dont listen for CUSTOM Events
Post by: isragaytan on May 18, 2009, 02:51:11
Thanks Cliff!

Now its working!!...

The problem as yo say its in the CUSTOM event..

my Code working on the custom Events its..

package org.cdi.cdiintegra.socios.views.events
{
   import flash.events.Event;

   public class BusquedaRFCEvent extends Event
   {
      
      public var strRfc:String;
   
      public function BusquedaRFCEvent(strRfc:String,type:String)
      {
         super(type,true,true);
         this.strRfc=strRfc;
      }
      
      override public function clone():Event{
         
         return new BusquedaRFCEvent(strRfc,type);   
      }
      
      }

   
}

Thanks a lot again!