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 [2]
16  PureMVC Manifold / Demos and Utils / Re: Small Sequencing Issue on: August 27, 2009, 07:00:34
Just to clarify about 'loaded' notifications in the Loadup utility.  The release notes in version.txt state:
    On loaded and failed notifications sent by the client app, if
    the monitor proxyName is not the default name, the notification
    type MUST BE the monitor proxyName.

So, type should be empty unless the LoadupMonitorProxy has been given a custom name.

This business of SRNAME may have arisen from the LoadupAsOrdered demo, where there are code instances like sendLoadedNotification( blah_LOADED, NAME, SRNAME ). This 'sendLoadedNotification' method is local to the demo; it is not part of the Loadup API.
----Philip

Thanks Philip.
I am getting this error even though I have not give the LoadupMonitorProxy a custom name.

:
Sent ApplicationFacade/action/startup
Sent ApplicationFacade/note/started
Sent ApplicationFacade/action/showSplashScreen
Sent ApplicationFacade/action/loadResources
Sent ApplicationFacade/note/loading_projects
Error: null: Unknown ILoadupProxy in loaded/failed notification, not known in LoadupMonitorProxy instance named :LoadupMonitorProxy
at org.puremvc.as3.multicore.utilities.loadup.model::LoadupMonitorProxy/resolveAppProxyNameElseError()[C:\My Documents\Flex Builder 3\PureMVC\Utility_AS3_Loadup_2_0\multicore\org\puremvc\as3\multicore\utilities\loadup\model\LoadupMonitorProxy.as:485]
at org.puremvc.as3.multicore.utilities.loadup.model::LoadupMonitorProxy/resourceLoaded()[C:\My Documents\Flex Builder 3\PureMVC\Utility_AS3_Loadup_2_0\multicore\org\puremvc\as3\multicore\utilities\loadup\model\LoadupMonitorProxy.as:448]
at org.puremvc.as3.multicore.utilities.loadup.controller::LoadupResourceLoadedCommand/execute()[C:\My Documents\Flex Builder 3\PureMVC\Utility_AS3_Loadup_2_0\multicore\org\puremvc\as3\multicore\utilities\loadup\controller\LoadupResourceLoadedCommand.as:46]
at org.puremvc.as3.multicore.core::Controller/executSent ApplicationFacade/note/projects_loaded

When the projects are returned from the service I am sending an ApplicationFacade.PROJECTS_LOADED notification that was registered as a resource loaded notification.  I think this wrong because isn't this the notification that loadup sends when the resources have finished loading?  I tried not sending any notifications from the loaded function to see if ApplicationFacade.PROJECTS_LOADED is sent by the Loadup Utiltity, but it is not.

I know these posts have hit a lot of different areas.  But I appreciate your patience and assistance.
Thank you.

:
   
ApplicationFacade
registerResourceLoadedCommand( PROJECTS_LOADED );
registerResourceFailedCommand( PROJECTS_LOADING_FAILED );

ProjectProxy
    // remote login procedure is successfull
        public function loaded( asToken:Object=null ):void {       
        var projects:Array = [];
        for each ( var item:Object in asToken.result ) {
        projects.push( { label: item.domain, data: item.domain } );
        }
setData( projects );
sendNotification( ApplicationFacade.PROJECTS_LOADED, data );
        }

But in the LoadResourcesCommand i am using the default name.

:
public class LoadResourcesCommand extends SimpleCommand implements ICommand
{
private var monitor:LoadupMonitorProxy;

public override function execute( note:INotification ):void {
facade.registerProxy( new LoadupMonitorProxy() );
this.monitor = facade.retrieveProxy( LoadupMonitorProxy.NAME ) as LoadupMonitorProxy;

var projectProxy:ILoadupProxy = new ProjectProxy();
facade.registerProxy( projectProxy );

var rProjectPx:LoadupResourceProxy = makeAndRegisterLoadupResource( ProjectProxy.NAME, projectProxy );
this.monitor.loadResources();
}

private function makeAndRegisterLoadupResource( proxyName :String, appResourceProxy:ILoadupProxy ):LoadupResourceProxy {
var r:LoadupResourceProxy = new LoadupResourceProxy( proxyName, appResourceProxy );
facade.registerProxy( r );
monitor.addResource( r );
return r;
}
}

17  PureMVC Manifold / Demos and Utils / Re: Small Sequencing Issue on: August 25, 2009, 08:10:39
Thank you Cliff.  That's what I was doing. 

PolyKron. You are right. I was trying to get the State Machine to do what the Loadup was meant to do.  I got it to work. Somewhat. I created my ProjectProxy as an ILoadupProxy. 

I thought I could send the proxy's project data with the ApplicationFacade.PROJECTS_LOADED notification.  I was following the LoadupAssets example. It sends the notification as sendNotification( ApplicationFacade.PROJECTS_LOADED, NAME, SRNAME ); I am not sure of the purpose of SRNAME.  So to get my list of projects I had to send another notification sendNotification( ProjectProxy.PROJECTS_RETRIEVED, data  );.  But doing it this way I think may be overriding the purpose of the Loadup utility in terms of blocking until the startup data is available.  When I run it the UI is displayed and then a few seconds later the combo box is populated.  Is this where the state machine would come in handy?
At first I had my LoginFormMediator listening for the LoadupMonitorProxy.LOADING_COMPLETE: notification.  Now my ApplicationMediator is interested LOADING_COMPLETE but I am not doing anything with the note.  I don't want the login page displayed if the project fail to load so maybe the ApplicationMediator should be responsible for handling that scenario?
Is the following the correct way to return the Proxy's project data to the interested mediator?  Am I breaking the chain of events by sending both notifications when the data is retrieved from the Project Proxy?

Thank you.

:

public class ProjectProxy extends EntityProxy implements ILoadupProxy
{
        //  send LoginAttempt as proxy data
public function ProjectProxy() {
super( ProjectProxy.NAME );
}

// notification name constants
public static const NAME:String = "ProjectProxy";
public static const SRNAME:String = 'ProjectSRProxy';
public static const PROJECTS_RETRIEVED:String = NAME+'/notes/projects_retrieved';
public static const PROJECTS_RETRIEVAL_FAILED:String = NAME+'/notes/projects_retrieval_failed';

// project service
        private var projectService:RemoteObject;
        private var tryCount:int = 0;
       
// configure the proxy when registered
public override function onRegister():void {
// configure the remote object
        projectService  = new RemoteObject("GenericDestination");
        projectService.source = "ProjectService";

        // is this ok? Had do listen for the remote call.  I thought this would be inherited behaviour
        projectService.getOperation("getProjects").addEventListener( ResultEvent.RESULT, loaded );
        projectService.getOperation("getProjects").addEventListener( FaultEvent.FAULT, failed );
}

// call the remote object service
public function load():void {
        tryCount++;   
        sendNotification( ApplicationFacade.PROJECTS_LOADING, NAME, SRNAME );
        projectService.getProjects();
}
       
// remote procedure is successfull
public function loaded( asToken:Object=null ):void {       
        var projects:Array = [];
        for each (var item:Object in asToken.result ) {
        projects.push( { label: item.domain, data: item.domain } );
        }
         
setData( projects );
        // not sure what this is for
        sendNotification( ApplicationFacade.PROJECTS_LOADED, NAME, SRNAME );
        // this is how I am sending the retrieved data.
      sendNotification( ProjectProxy.PROJECTS_RETRIEVED, data  ); 
}
       
// remote login procedure is successfull
public function failed( asToken:Object=null ):void {         
    sendNotification( PROJECTS_RETRIEVAL_FAILED ); 
}
18  PureMVC Manifold / Demos and Utils / Re: Small Sequencing Issue on: August 23, 2009, 04:31:28
Hi,

If you are in a StateMachine logic for the main application, you could use StateMachine in all other "components" or Modules... Each Core can have its own StateMachine (you have to use the multicore package for that).

The way you use StateMachine seems not to be the right way.. You should have one State Machine for your main app with two views LOGIN and POPULATE COMBO.
And in each view, other StateMachines or Notifications handlers to swap between components view.
 
For your FSM, i think the one you provide would be for the Project loading module... not for the main one.. and don't forget to define the target state in your FSM :

ApplicationFacade.STARTUP_FAILED,ApplicationFacade.PROJECTS_LOADED and ApplicationFacade.PROJECTS_LOADING_FAILING

regards

:::Poly:::
Hi.  I am still confused.  I just need to projects to load before the user can interact with the app.  Maybe the startup monitor is more appropriate since it is a startup resource?  I was trying to define my FSM so that after puremvc is started up the projects would load to the combo box.  Still not getting it.
19  PureMVC Manifold / Demos and Utils / Re: Small Sequencing Issue on: August 21, 2009, 11:16:07
Thank you for responding.  What about the states of one component vs. application state?  My login screen component has 4 different states. LOGIN, REGISTER, CHANGE PASSWORD and RESET PASSWORD.  Should all of these be managed by the state machine? Or is that for more application scope state, like moving from the Login page to the Main application page?  Should the view component state be handled only by the component's mediator? Since the first application state change would be once the user logged in successfully. Until that point everything is on one view. 


Also, I want to load a list of projects to a combo box prior to showing the login view.  I am attempting to do this by mapping an APPLICATION.STARTUP action to an APPLICATION.LOAD_PROJECTS.  I want my application mediator to respond to the notification and call the projectProxy to load the projects.  I have defined the FSM like this:

:
<fsm initial={ApplicationFacade.STARTING}>
<state name={ApplicationFacade.STARTING}><transition action={ApplicationFacade.ACTION_STARTUP} target={ApplicationFacade.LOAD_PROJECTS}/>
<transition action={ApplicationFacade.STARTUP_FAILED} target={ApplicationFacade.STARTUP_FAILED}/>
</state>
<state name={ApplicationFacade.LOAD_PROJECTS}><transition action={ApplicationFacade.LOAD_PROJECTS} target={ApplicationFacade.PROJECTS_LOADED}/>
<transition action={ApplicationFacade.PROJECTS_LOADING_FAILED} target={ApplicationFacade.PROJECTS_LOADING_FAILING}/>
</state>
</fsm>;


Thank you.
20  PureMVC Manifold / Demos and Utils / Small Sequencing Issue on: August 19, 2009, 06:53:25
Hello.  This is my first major flex/puremvc project.  I am still on the login/logout functionality but its helped me get started with what the players are supposed to do.  It has taken me long to get going but I think I am making good progress thanks to everyone here.

However, I am still confused about a few things like, THE STATE MACHINE, when I should use a command vs just calling the proxy method from the mediator, how to keep viewComponent code out of the mediator by sending notifications that invoke commands and what it means to 'put business logic in the commands'  when the only thing I typically see in commands in examples is the command getting data from the note and invoking a proxy method. I hoping to find a good complex command example.

Anyway, for this post my question is about a sequencing issue.
My login view has 4 states.  Login, Registration, Reset Password and Change Password.  When the user registers successfully I show an alert telling them that the registration was successful.  When the user clicks the alert 'OK' button, I want the following to happen:

1.  Enable the form.
2.  Clear the form.
3.  Go back to the Login state.
4.  Populate the userID with the userID from the registration VO.

To go back to the login state I am using an approach I found where the application proxy holds the view state property and sends a notification any time its changed and then the app mediator reacts by changing the view.  But the login form mediator is responsible for enabling the login form and clearing the form.  What is happening is that the form gets cleared and enabled but the app mediator doesn't get a chance to change the state.  Its a sequence issue because the app mediator gets the notification first and changes the state but I think calling the alert from the registration state makes it return.  Not sure.
I am wondering if this is where the State Machine or Macro Commands would come in handy.  The State Machine has been really intimidating to me but I knew at some point I would have to face it.  From what I understand Macro Commands are a way of chaining and sequencing events. My startup command is a macro command.  Is this what I should be doing in this scenario?  Or is this something the state machine would be good for.

Thanks.

21  PureMVC Manifold / MultiCore Version / "Error: multitonKey for this Notifier not yet initialized!" problem. HELP!! on: August 14, 2009, 04:26:14
Hello.  For some reason i am getting the Error: multitonKey for this Notifier not yet initialized!" error even though I only call the facade from the onRegister() function in the Mediators and from the execute() functions of the Commands.  I don't reference the facade at all in the onRegister functions of the proxies that I register on startup.  I am using the StartupCommand from an example I found that extends the MacroCommand.  All of this started happening after I tried to implement the StartupManager.  I wanted to pull some values from the database to populate a combo box that the user can set when logging in.  I didn't want the login view to be displayed if the combo box values are not populated.  I thought this thought the error was caused by making changes while going through the StartupManager getting started tutorial, but I changed everything back and I am still getting the error.  VERY FRUSTRATING!!  It absolutely worked before.  All of the posts I see on this topic say that it is because you have to get the facade.retrieve() from the onRegister() and I have done that.  Is there something else I am missing?  Thank you.

// Startup Command
:

public class StartupCommand extends MacroCommand
{
        override protected function initializeMacroCommand():void {
            addSubCommand( ModelPrepCommand );
            addSubCommand( ViewPrepCommand );
        }
}

// Model Prep Command
:
public class ModelPrepCommand extends SimpleCommand
{
override public function execute(note:INotification):void
{
facade.registerProxy( new ApplicationProxy() );
facade.registerProxy( new UserProxy() );
facade.registerProxy( new LoginProxy() );
facade.registerProxy( new RegistrationProxy() );
}
}

// View Prep Command
:
override public function execute( note:INotification ):void
{
var app:MYMVCAPP = note.getBody() as MYMVCAPP;
facade.registerMediator( new ApplicationMediator( app ));
}
Pages: 1 [2]