Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
December 18, 2017, 07:45:32 AM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: Mediator removes throw error  (Read 5930 times)
eranda
Newbie
*
Posts: 3


View Profile Email
« on: March 24, 2011, 09:38:26 AM »

Hi

Iím 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 mediatorís 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
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« Reply #1 on: March 25, 2011, 07:54:03 AM »

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>
Logged
eranda
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: March 28, 2011, 12:02:08 AM »

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
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« Reply #3 on: March 28, 2011, 07:49:45 AM »

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>
« Last Edit: March 28, 2011, 07:51:20 AM by puremvc » Logged
eranda
Newbie
*
Posts: 3


View Profile Email
« Reply #4 on: March 28, 2011, 11:18:02 PM »

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



Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW
« Reply #5 on: April 01, 2011, 09:43:19 AM »

Quote
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.

Quote
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:

Quote
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 mediatorís 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>
Logged
Pages: [1]
Print
Jump to: