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 / Thoughts on Robotlegs on: August 03, 2010, 06:27:41
Hello everybody,

As you know, Robotlegs has been making some noise lately and I'd like to read some of your thoughts about it.

I would be great if we could do a pro-cons table.
2  Announcements and General Discussion / Architecture / Re: Quick question about mediators on: September 08, 2009, 01:10:15
I really like reading other people perspective about an issue. Thank you for your response Cliff.
3  Announcements and General Discussion / Architecture / Re: Registering mediators on: September 08, 2009, 10:11:17
Oh, thanks Cliff.
4  Announcements and General Discussion / Architecture / Re: Quick question about mediators on: September 08, 2009, 07:02:14
Good, thanks. I thought about this all night, and that suits as a better solution.
5  Announcements and General Discussion / Architecture / Quick question about mediators on: September 07, 2009, 03:35:10
Is it a good practice to register mediators only if they are needed?

For example, I have a notification two mediators are listening, BUT While I am on view1, I want the view1 mediator listen to this notification, and not the view2 mediator.

So I figured, instead of creating a notification for EACH view, I was wondering if I better register the mediator when I am gonna need it and then when I go out of the view, I unregister it.

Points of view about this, anyone?
6  Announcements and General Discussion / Architecture / Re: Registering mediators on: September 05, 2009, 02:22:52
Lol, I never thought I'd reply myself on this. Although I still want an explaination here.

It seems like.. when I try to register Mediators in an altered order, it throws this error.

I had another component before the DisplayView view component, this was FlexNativeMenu. So what I did was registering the mediator of the FlexNativeMenu as NativeMenuMediator BEFORE registering the Mediator for the DisplayView view component. Let me post the source here:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication
   xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/halo"
   xmlns:view="view.components.*"
   width="800" height="600"
   minWidth="700" minHeight="600"
   creationComplete="facade.startup(this);">
   
   <fx:Style source="assets/css/Application.css"/>
   
   <s:layout>
      <s:VerticalLayout horizontalAlign="center"/>
   </s:layout>
   
   <fx:Script>
      <![CDATA[         
         public var facade:ApplicationFacade = ApplicationFacade.getInstance();
      ]]>
   </fx:Script>
   
   <fx:Declarations>
      <fx:XML id="nativeMenuDataProvider" source="assets/xml/menus_es_ES.xml" format="e4x"/>
   </fx:Declarations>

   <s:menu>
      <mx:FlexNativeMenu id="nativeMenu" labelField="@label" keyEquivalentField="@keyEquivalent" showRoot="false" dataProvider="{nativeMenuDataProvider}"/>
   </s:menu>
   
   <view:DisplayView id="displayView" width="100%" height="100%"/>   
</s:WindowedApplication>

For some reason, if I don't register a mediator for the FlexNativeMenu view component before registering the mediator for the DisplayView view component, I get the error.

I would make sense if once I have to keep the order of the creation of the parent's child, but.. I'd like to hear a logic explaination for this.

I am assuming that if the FlexNativeMenu was not there, it woulda worked perfectly.
7  Announcements and General Discussion / Architecture / Registering mediators on: September 05, 2009, 10:54:10
Hello everybody,

I am getting some errors when I register a mediator for my Application's child.

I have a method in my ApplicationFacade called startup() which I call withing the creationComplete event handler of my Application.mxml. This method sends a notification STARTUP, which is registered with a Command called StartupCommand in which I register a mediator called ApplicationMediator.

Now in my Application.mxml I have a view component called DisplayView, which contains a ViewStack with two other view components, LoginView And MainView. The viewstack selectedindex is by default set to 0 and creationPolicy set to auto.

Well, I created a mediator for DisplayView view component called DisplayViewMediator which I am registering on the onRegister() method of my ApplicationMediator.

After I did all this, my app won't run, it throws me errors referencing the line where I am registering the DisplayViewMediator.

I'll paste the error here:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at org.puremvc.as3.core::View/registerMediator()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3\src\org\puremvc\as3\core\View.as:189]
   at org.puremvc.as3.patterns.facade::Facade/registerMediator()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3\src\org\puremvc\as3\patterns\facade\Facade.as:337]
   at view::ApplicationMediator/onRegister()[C:\Users\Renato\Work\flex\tnekvoip_admin\source\src\cl\tnek\voipadmin\view\ApplicationMediator.as:18]
   at org.puremvc.as3.core::View/registerMediator()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3\src\org\puremvc\as3\core\View.as:201]
   at org.puremvc.as3.patterns.facade::Facade/registerMediator()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3\src\org\puremvc\as3\patterns\facade\Facade.as:337]
   at controller::StartupCommand/execute()[C:\Users\Renato\Work\flex\tnekvoip_admin\source\src\cl\tnek\voipadmin\controller\StartupCommand.as:12]
   at org.puremvc.as3.core::Controller/executeCommand()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3\src\org\puremvc\as3\core\Controller.as:115]
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at org.puremvc.as3.patterns.observer::Observer/notifyObserver()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3\src\org\puremvc\as3\patterns\observer\Observer.as:100]
   at org.puremvc.as3.core::View/notifyObservers()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3\src\org\puremvc\as3\core\View.as:126]
   at org.puremvc.as3.patterns.facade::Facade/notifyObservers()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3\src\org\puremvc\as3\patterns\facade\Facade.as:404]
   at org.puremvc.as3.patterns.facade::Facade/sendNotification()[C:\Documents and Settings\Owner.CapricornOne\My Documents\My Workspaces\PureMVC\PureMVC_AS3\src\org\puremvc\as3\patterns\facade\Facade.as:387]
   at ApplicationFacade/startup()[C:\Users\Renato\Work\flex\tnekvoip_admin\source\src\cl\tnek\voipadmin\ApplicationFacade.as:34]
   at Application/___Application_WindowedApplication1_creationComplete()[C:\Users\Renato\Work\flex\tnekvoip_admin\source\src\cl\tnek\voipadmin\Application.mxml:9]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at mx.core::UIComponent/dispatchEvent()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\UIComponent.as:11260]
   at mx.core::UIComponent/set initialized()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\UIComponent.as:1513]
   at mx.managers::LayoutManager/validateClient()[E:\dev\beta1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:988]
   at mx.core::UIComponent/validateNow()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\UIComponent.as:6881]
   at spark.components::WindowedApplication/window_resizeHandler()[E:\dev\beta1\frameworks\projects\airframework\src\spark\components\WindowedApplication.as:2609]
   at flash.display::NativeWindow/set _menu()
   at flash.display::NativeWindow/set menu()
   at spark.components::WindowedApplication/commitProperties()[E:\dev\beta1\frameworks\projects\airframework\src\spark\components\WindowedApplication.as:1681]
   at mx.core::UIComponent/validateProperties()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\UIComponent.as:7019]
   at mx.managers::LayoutManager/validateProperties()[E:\dev\beta1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:572]
   at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\beta1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:700]
   at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\beta1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1067]

I uploaded the source files zipped so you can give me a hand with this. I really don't understand what is going on here. I checked if the reference to the viewComponent passed into the mediator constructor is null by tracing it, and it is not null, it is not, it prints this:

Application0.WindowedApplicationSkin2.Group3.Group4.DisplayView6

Thanks in advance.

Edit: If I comment out the line that registers the DisplayViewMediator, the applications works.

The link to the source files are here: http://www.tnek.cl/source.zip
8  PureMVC Manifold / Standard Version / Re: Register Mediator on: September 04, 2009, 07:32:09
Thank you Cliff.
9  Announcements and General Discussion / Architecture / Re: Q;Architecting a PureMVC Video Player on: September 03, 2009, 07:51:15
Proxies are the one who brings external data to the system. So managing the states in proxies should not be proxies duty. You could manage states in mediators instead.

I think it will depend on the logic of your custom components. If a component has a lot of stuff to interact with, sometimes it is better to isolate it and create a mediator that deals with all the interactions and notify to a command if you need more complex logic.

I got started a few days ago with PureMVC and so far, I think it is pretty straight forward. I see it like this:

Components
Visual part, user interacts with it. Every interaction dispatches an event WHICH a mediator can handle. If this component have several ways to interact with, then it would be probably a better choice to create a mediator for this component, otherwise you could always use the component's parent mediator.

Mediator
These are the ones responsible to handle interactions between the user and a component. A component does not know a mediator exists, only the mediator knows the component exist. Mediators could retrieve. You could handle lightweight logic in mediators, but heavier logic, you shall delegate this to a command.

Command
Well, I see these as literal "commands" you call for a certain action. For example, I have an application which have actions like: AddClient, EditClient. I usually connect one command to a proxy. The command retrieves the proxy to call a remote object, save client to database, edit client info, etc.

Commands for me are like a bridge between Mediators and Proxy. I don't like the idea of retrieving Proxys directly from Mediators, I like using Commands instead. A command for each action.

Proxies
These guys are brings the fun to the application. they load data, query local db (AIR), remote objects, load assets, etc. And pass it on to the command in case you need to do some logic before pass it to the mediator.

I'd love and really appreciate someone can correct myself if I didn't get something straight, but so far, this is how I understand PureMVC.

Edit: Sorry echo_bach, but in your case what I'd do is, create mediators for complex components, to deal with their interactions as custom as I could, giving your application even more flexibility.

Handle states in proxy??? Nah, you can do this in mediators. so if your <mx:Application> have several states, you might want to create a "ApplicationMediator", which you register in the startup command.

A good practice would be, make StartupCommand a MacroCommand, and then in this MacroCommand, you add two subcommands: "SetupViewCommand" and "SetupModelCommand".

In SetupModelCommand you register the proxies you will be using and in the SetupViewCommand you register the mediators, which is a perfect place to register the ApplicationMediator.

If you need a clear example of this, you can check this PDF: http://puremvc.org/component/option,com_wrapper/Itemid,174/
10  PureMVC Manifold / Standard Version / Re: Register Mediator on: September 03, 2009, 09:54:23
Good, that's what I wanted to hear, either a confirmation of what I was thinking or a different view.

I thought that was the most logical way to do it:

It's quite appropriate to have mediators register other meditros for it's components children

I just wasn't sure if mediators registering other mediators was proper or okay with the puremvc paradigma/conventions.
11  PureMVC Manifold / Standard Version / Re: Register Mediator on: September 03, 2009, 07:11:28
Hello,

I just got started with PureMVC, I think it is great but I have some doubts.

I've got a MacroCommand which Execute two subcommands which are: SetupModelCommand & SetupViewCommand.

In SetupModelCommand I register the required proxies and in SetupViewCommand I register the required Mediators, BUT.

I have a mediator called: AppControlBarMediator, which I can't initialize here, because it is a Mediator of a component which is a child of a VIEW (viewComponent), which has not been created yet because it is another state of my application.

I have two states for my application: LoginView and MainView.

So I thought for a minute and the only logic solution I found to this is, create a Mediator for my MainView, and on the "creationComplete" event of this view, send a notification to the MainViewMediator, in WHICH, I'd register the Mediator for the AppControlBar.

My doubt is, is there any "better practice" for where to register mediators or proxies? I read proxies can be retrieved from Mediators and Commands, but it is more proper to register them in the command.

I'd like to hear some opinions about this. I like following conventions and keep the code in order, so that's why I stumble on these silly details.

Shall Mediators be registered anywhere or is there an order? Is it recommended to unregister Mediators or Proxies if I am not going to use them anymore? I know it sounds logical but I'd like to hear opinions.
Pages: [1]