PureMVC Architects Lounge

PureMVC Manifold => MultiCore Version => Topic started by: eranda on March 24, 2011, 09:38:26



Title: Mediator removes throw error
Post by: eranda on March 24, 2011, 09:38:26
Hi

Im using the multicore 1.0.5 for my application. It throw the following error when remove the mediator.  It happens when the listNotificationInterests has a notification that not listen any other mediator in the application.  In other words, if I put the notification name to a another mediators listNotificationInterests array, the error will not throw.

ypeError: Error #1009: Cannot access a property or method of a null object reference.
    at org.puremvc.as3.multicore.core::View/removeObserver()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\core\View.as:144]
    at org.puremvc.as3.multicore.core::View/removeMediator()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\core\View.as:245]
    at org.puremvc.as3.multicore.patterns.facade::Facade/removeMediator()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\facade\Facade.as:250]


Any solution ?'

Thanks in advance


Title: Re: Mediator removes throw error
Post by: puremvc on March 25, 2011, 07:54:03
I assume this is in an existing application you've run into this problem? Can you put this in a petri dish? Write a tiny project that just registers and removes the mediator. Can you reproduce the problem from that approach? If so, can you post it here in a zip file?

-=Cliff>


Title: Re: Mediator removes throw error
Post by: eranda on March 28, 2011, 12:02:08
I have attached the simple flex project for reproduce it. You will find the fxp file and the flex project folder too. I used flex SDK 4.1.

Thanks

Eranda


Title: Re: Mediator removes throw error
Post by: puremvc on March 28, 2011, 07:49:45
Attached is your project working without error. The TestMediator1 class responds to the REMOVE_MEDIATOR note by removing itself.

You had some whacky stuff going on where you registered the StartupCommand to the REMOVE_MEDIATOR notification for some reason. Since this is also the notification used to remove the mediator, it's questionable why you'd want to do this.

You also had TestMediator1 subclassing an unnecessary AbstractTestMediator, which I removed for simplification. If you want to return an empty array from listNotificationInterests, you don't need to create an abstract class or override the listNotificationInterests method at all; the framework superclass already does that.

-=Cliff>


Title: Re: Mediator removes throw error
Post by: eranda on March 28, 2011, 11:18:02
You had some whacky stuff going on where you registered the StartupCommand to the REMOVE_MEDIATOR notification for some reason. Since this is also the notification used to remove the mediator, it's questionable why you'd want to do this.
-=Cliff>

This is my bad. StartupCommand command should registered to the notification like STARTUP I have corrected it. but still error is popup for me.

Attached is your project working without error.
-=Cliff>

This is strange. I just downloaded the files I uploaded and make imported to the flash builder. still shows the flash error message when i click the 'remove mediator' button in the UI.


You also had TestMediator1 subclassing an unnecessary AbstractTestMediator, which I removed for simplification. If you want to return an empty array from listNotificationInterests, you don't need to create an abstract class or override the listNotificationInterests method at all; the framework superclass already does that.
-=Cliff>


Note that subclassing the TestMediator1  is necessary  for my real application. I subclassing many mediators from the AbstractTestMediator. because it implemented the common abstract business logic for all mediators like TestMediator1.

Following shows the sample code AbstractTestMediator class has.


               override public function initializeNotifier(key:String):void
      {
         super.initializeNotifier(key);
         
         if(this.dynamicNote != null)
         {
            var name:String
            for(var i:int=0; i<dynamicNote.length; i++)
            {
               notificationInterests.push(name);   
            }
         }
      }   
So you can see I'm adding the notification dynamically to the 'notificationInterests' array in AbstractTestMediator class. therefore it's not empty sometime. (I have added the above code to the attachment of this post)


I have noted if I remove the AbstractTestMediator and extend the TestMediator1  from Mediator, the error won't throw.


Thanks

Eranda





Title: Re: Mediator removes throw error
Post by: puremvc on April 01, 2011, 09:43:19
Quote from: puremvc on March 28, 2011, 07:49:45 AM
Attached is your project working without error.
-=Cliff>

This is strange. I just downloaded the files I uploaded and make imported to the flash builder. still shows the flash error message when i click the 'remove mediator' button in the UI.

I didn't change the files you uploaded, I attached the modified project to my reply. Note that your original zip was 69k and the one I attached was 32k.

Here's the direct link:
http://forums.puremvc.org/index.php?action=dlattach;topic=1896.0;attach=163

You should definitely delete your existing flashbuilder project before importing this one.

Note that subclassing the TestMediator1  is necessary  for my real application.
True, but it was not necessary for a petri-dish project aimed at proving the original point, which was:

It throw the following error when remove the mediator.  It happens when the listNotificationInterests has a notification that not listen any other mediator in the application.  In other words, if I put the notification name to a another mediators listNotificationInterests array, the error will not throw.

I removed the abstract mediator for simplification because it added nothing to the test. For the sake of this discussion, I don't think having an abstract mediator had anything to do with the problem, I use them often.

Now, the initializeNotifier method you include above makes me wonder about the lifecycle of this mediator. For instance, where is dynamicNote set if this is happening in the initializeNotifier phase?

-=Cliff>