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

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / General Discussion / Re: How to properly manage application states on: January 14, 2009, 07:51:17
Well I changed the StateMachine in a way that the exiting notification has a type that corresponds to the action (the action that caused state change). The command/mediator that listens to that (state exiting) notification can hold the action and launch it later.

Also, the state entering notification has the currentState as the body, instead the nextState, and also the action.

This way each state entering/exiting notification knows which action caused the state change.

These are little changes that I think you should consider adding to the framework.

Regards,
Nuno
2  Announcements and General Discussion / General Discussion / Re: How to properly manage application states on: January 14, 2009, 02:07:28
Hi,

I really had to resolve this question afternoon while I didn't a reply from you. So what i did was to create an intermediate state to hold until the user input.

Its is not a clean solution but it works.

If you guys have a cleaner solution please tell me.

Thanks,

Nuno
3  Announcements and General Discussion / General Discussion / Re: How to properly manage application states on: January 14, 2009, 10:45:16
Hi Cliff,

I have tried the AsyncCommand but this is not solving the problem as the transition is being executed. Please check what i'm doing:

In facade:

registerCommand(EFFECT_SAVE_CONFIRM, EffectSaveConfirmAsyncCommand);

In EffectSaveConfirmAsyncCommand definition

:
{
    public static const CANCEL_EFFECT:String = 'EffectSaveConfirmAsyncCommand.cancelEffect';
    public static const SAVE_EFFECT:String = 'EffectSaveConfirmAsyncCommand.saveEffect';
    public static const LOAD_EFFECT:String = 'EffectSaveConfirmAsyncCommand.loadEffect';
   
        override public function execute ( note:INotification ) : void
        {
        var confirmPopUpMediator:ConfirmPopUpMediator = PopUpManager.openPopUpWindow(ConfirmPopUp,ConfirmPopUpMediator) as ConfirmPopUpMediator;
                confirmPopUpMediator.confirmPopUp.type = ConfirmPopUp.CANCELNOYES;
                confirmPopUpMediator.confirmPopUp.title = 'SAVE EFFECT';               
                confirmPopUpMediator.confirmPopUp.message = "Current effect has been changed. Do you want to save the changes?";
                confirmPopUpMediator.confirmPopUp.closeHandler = closeHandler;
               
           
        }
       
        private function closeHandler(event:EventWithParameter):void
        {
            if (event.data == ConfirmPopUp.YES)
            {         
                sendNotification(SAVE_EFFECT);
            }
            else if (event.data == ConfirmPopUp.CANCEL)
            {
                sendNotification(CANCEL_EFFECT);                                           
            }
            else
            {
                sendNotification(LOAD_EFFECT);                                     
            }

            // commandComplete();    this gives error if not commented
         }
    }

In FSM definition:

<state name={Main.STATE_EFFECT_EDITOR} entering={ApplicationMediator.SHOW_EFFECT_EDITOR} exiting={ApplicationFacade.EFFECT_SAVE_CONFIRM}>
                   <transition action={EffectEditor.RETURN_TO_EFFECTS_WORKBENCH} target={Main.STATE_EFFECTS_WORKBENCH}/>
                   <transition action={EffectEditor.RETURN_TO_TIMELINE_EDITOR} target={Main.STATE_TIMELINE_EDITOR}/>
               </state>

Thanks,

With my best regards,

Nuno Santos

4  Announcements and General Discussion / General Discussion / Re: How to properly manage application states on: January 14, 2009, 07:15:27
Hi Cliff,

Thanks for you reply.

I have never used AsyncMacroCommand. Can you give a quick example on how to achieve it?

In the meanwhile i'll try to sort it out by myself.

And yes, I'll keep you updated.

Thanks,

Nuno

5  Announcements and General Discussion / General Discussion / Re: How to properly manage application states on: January 14, 2009, 04:55:53
Hi guys,

Thanks for your support.

I don't have a concrete position about transitions to the same state. However I have a new question:

Imagine the following situation. I'm in state A and I want to go to state B. On the exiting actions of A I have a method that verify if there is something to save. If so, a dialog appears asking user input.

I don't want to go to state B while the user has not given its input.

For that i had to cancel the transition by the time of the exiting notification handling. But I don't have a way of resuming the transition without an external hack.

Is there any clean way of doing this?

Thank you very much,

With my best regards,

Nuno Santos
6  Announcements and General Discussion / General Discussion / Re: How to properly manage application states on: January 12, 2009, 11:48:53
Hi,

I have tried the State Machine and it's seems a powerfull and unviesal way of defining states. Now i have the following question:

I have 8 sections which represent 8 possible main states. When i'm in a state i can go to other 7. This is at least something like 56 possible states.

What I want to know is if there is any way of bypassing the description of some basic transitions.

Example:

I have the Section 1, 2 and 3. From section one i can go to section 2 and 3. If i'm in section 2, i can go to section 1 and 3, etc.

Thanks,

Nuno
7  Announcements and General Discussion / General Discussion / How to properly manage application states on: January 09, 2009, 08:28:15
Hi,

I'm building a complex application in flex with puremvc which envolves the managment of several sections with subsections, etc.

For example, when I want to switch between sections I need to have sure that the actual section has nothing to save.

Other case is for example when I'm in a following section and I use data of that section as input of the target section and then i want to get back to the original section.

Basicly what i need is somekind of state manager to handle confirm dialogs and switch between sections.

This must be a very common problem so I would love to hear the best way of doing this taking advantages of the pure mvc framework.

Thanks in advance,

With my best regards,

Nuno Santos
8  Announcements and General Discussion / Getting Started / Proxy notification for multiple mediators on: November 19, 2008, 08:48:32
Supose there are two mediators M1 and M2. There is also a proxy P that has a method list(path:String). This method will use a HTTPService to retrieve data. Once data is returned proxy P sends a notification. Both mediators M1 and M2 have interest on that notification.

Now, M1 retrieves the proxy P and calls list('fooo'). What is the best way to make sure M2 won't do a thing with the result notification?

Is it better to have a HTTPService for each mediator? Should both mediators check the notification body if they must ignore it?

Thanks
9  Announcements and General Discussion / Getting Started / facade has proxy but it is null on: October 15, 2008, 03:54:55
Hi,

I'm trying to retrieve a proxy from the facade but it comes null... dont understand why since its being constructed and initialized correctly.

This is what i'm doing:

accessProxy = facade.retrieveProxy(AccessProxy.NAME) as AccessProxy;

var loginVO:LoginVO = note.getBody() as LoginVO;
         var accessProxy:AccessProxy;
         
         if (facade.hasProxy(AccessProxy.NAME)) {
         
            accessProxy = facade.retrieveProxy(AccessProxy.NAME) as AccessProxy;
            
            if (accessProxy!=null)
               accessProxy.login(loginVO);
            else
               mx.controls.Alert.show("null proxy");
         }
         else {
            mx.controls.Alert.show("Couldn't obtain proxy");
         }

The proxy exists but it comes null.

Any tips?

Thanks,

Nuno Santos
10  Announcements and General Discussion / Getting Started / Can i send notifications from mediators to proxies? on: October 15, 2008, 02:30:44
Hi,

Before I started doing anything in puremvc i read half of the documentation and try to put the example on the documentation working. I was a little bit disapointed with the example because it was not a complete sample.

In the example, the login command is declaraded on the application facade and then, onTryLogin a notification is sent for that.

However, in the diagram, its possible to comunicate directly between mediators and proxies and thats what i'm trying to do, but its not working.

This is what i'm doing in my mediator:

override public function listNotificationInterests():Array {
            return [AccessProxy.LOGIN,
                  AccessProxy.LOGIN_FAILED,
                  AccessProxy.LOGIN_SUCCESS];
      }
      
      override public function handleNotification(notification:INotification):void
      {
         switch(notification.getName()) {
            case AccessProxy.LOGIN:
               var loginProxy:AccessProxy = facade.retrieveProxy(AccessProxy.NAME) as AccessProxy;
               loginProxy.login(accessPanel.loginVO);
               mx.controls.Alert.show("notification sent");
               break;
         }
      }      
      
      private function onTryLogin(event:Event): void
      {                  
         sendNotification(AccessProxy.LOGIN,accessPanel.loginVO);   
      }

Can anyone clarify me this?

Thanks,

Nuno



11  Announcements and General Discussion / Getting Started / Re: Doub about sending that from view to mediator on: October 15, 2008, 01:49:16
Hi,

Thanks for your reply.

What about sending the notification right from the event in the view?

Does this breaks the model a lot?

Thanks,

Nuno
12  Announcements and General Discussion / Getting Started / Doub about sending that from view to mediator on: October 14, 2008, 10:11:06
Hi,

I'm trying to follow the good development guidelines of the pure mvc.

For that i'm making events in my buttons and then handle them in the mediator side.

The problem is that i need to send a parameter as well... How can i do that?

This is what i have:

// view side

public static const DELETE_USER:String = 'deleteUser';

<mx:Button label="Delete" click="sendEvent(DELETE_USER)" />

// mediator side

private function onDeleteUser():void
{
// i need to get the user id parameter
sendNotification( ApplicationFacade.USER_DELETE, usersList.selectedItem.@id );            
}

How can i do this?

Thanks

Nuno

13  Announcements and General Discussion / Getting Started / Re: Problems sending notification on: October 14, 2008, 08:50:24
Hi,

Its working!

I found a bug.

Thanks,

Nuno
14  Announcements and General Discussion / Getting Started / Re: Problems sending notification 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
15  Announcements and General Discussion / Getting Started / Problems sending notification 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
Pages: [1]