PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: chiekurs on September 09, 2007, 02:29:14

Title: Some novice questions
Post by: chiekurs on September 09, 2007, 02:29:14
Hey ppl!

I just started to use pureMVC just few days ago so I'm pretty new to it hence i might be missing some basic things.
Anyhow, everything is great, everything is working except that I ran into some  issues I don't really understand.
First of all I noticed that if I do like this:
override public function handleNotification(notification:INotification):void {
trace("getName "+notification.getName())
I get traces from notifications current mediator isn't subscribed to.
Is that normal behavior or a bug? If thats normal behavior listNotificationInterests implementation lose any sense.
I would be grateful if anyone could explain me this issue.

Other thing give a lot more head ache.
I have a mediator which is needed only while user haven't logged on - LoginForm. I assumed that it would be only logical if i remove that mediator after user has logged on so I made class StartApplicationCommand which does
facade.removeMediator(LoginFormMediator.NAME);but this gives me error message
Error #1009: Cannot access a property or method of a null object reference.What is it all about?

Third issue is that before making separate START_APPLICATION notifier I wanted to use USER_LOGIN_SUCESSFULL which should inform  LoginForm that it's job is done and then invoke StartApplicationCommand, but as I noticed StartApplicationCommand.execute is fired before this message gets to LoginForm hence it didn't  knew when to remove it's visual component.
Is there any best practices on this issue or I should just use two notifiers and thats a normal way?
Btw, when i had implemented this layout i didn't get any error from removeMediator call.
That seems inconsistent to me.

Anyhow, can some explain to me what is it all about?
Btw I like pureMVC a lot it really make my life developing RIA's a lot more easy.

Title: Re: Some novice questions
Post by: puremvc on September 09, 2007, 04:42:10

As for your mediator being notified of notifications to which it is not subscribed, no this is not normal. Could you attach a small example app that is demonstrating this behavior?

The last section of your comment, I'm not able to follow completely. I'm not really sure what your desired chain of events / notifications is, what's listening to what, etc.


Title: Re: Some novice questions
Post by: chiekurs on September 10, 2007, 12:13:31

Thanks for reply!

I just figured that first issue wasn't really happening, my own mistake. So it's perfectly alright with notifying.

About third issue - the layout I've tried was like this:
1. LoginFormMediator receives user interaction and passes notification LOGIN_DATA_READY to everyone else.
2. UserLoginCommand is attached to that notification and fires sessionProxy.login with proper arguments.
3. When sessionProxy receives callback from server side it broadcast notification USER_LOGIN_SUCESSFULL
4.1 LoginFormMediator is subscribed to USER_LOGIN_SUCESSFULL
which commands it to remove visual component
4.2 StartApplicationCommand is also attached to that notification and tries to remove LoginFormMediator from mediator list

Hence, as I've noticed StartApplicationCommand is executed earlier than LoginFormMediator notification so  LoginFormMediator visual comoponent stays on stage.

I have a suspicion that it is normal behavior and what I did it the right thing.
I've changed event chain so StartApplicationCommand isn't attached to USER_LOGIN_SUCESSFULL and when LoginFormMediator  receives USER_LOGIN_SUCESSFULL after it's done removing of visual component it notifies others of START_APPLICATION notification.

Hope this time i'm more clear :)

Title: Re: Some novice questions
Post by: puremvc on September 16, 2007, 12:10:29
I removed a misleading statement (and response) from the thread made very late while muzzy. Facade.removeMediator is in fact there (there was a time when it was not).

Your error:

but this gives me error message
Error #1009: Cannot access a property or method of a null object reference.

was most likely caused by the removeMediator issue that caused the 1.6 revision. See the Version 1.6 notes in the version.txt file in the current PureMVC distribution zip file.