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 ... 14 15 [16] 17
226  Announcements and General Discussion / General Discussion / Re: How to manage multi-view in one mediator? on: October 14, 2008, 10:40:22
The name of the mediator is all you need to be different.
:
facade.register(new Mediator('CustomName1', viewComponent);
facade.register(new Mediator('CustomName2', viewComponent);

A better way is to have your components return a unique name and use that in the constructor of the mediator.
:
public function Mediator(viewComponent:Object=null ) {
     super(viewComponent.getUniqueName(), viewComponent);
}
227  Announcements and General Discussion / Getting Started / Re: Problems sending notification on: October 14, 2008, 08:13:54
You don't need to retrieve the ApplicationMediator to send a notification, in fact it won't work as you have it. It is the facade that sends notifications. The following will do:
:
public class AccessGrantedCommand extends SimpleCommand {
     
      override public function execute (note:INotification) : void {
         mx.controls.Alert.show("im here1");
         mx.controls.Alert.show("NOTIFICATION SEN1");
         
         facade.sendNotification(ApplicationFacade.MAINDISPLAY_MODE);
      }
   }
I'd also recommend putting your third alert in the listener for MAINDISPLAY_MODE to check if the note is being sent, rather than in the command. What you had only says the command completed, not that the notification sent.
228  Announcements and General Discussion / General Discussion / Re: How to manage notifications? on: October 14, 2008, 07:59:32
Since notifications use static var names [SOME_NAME], and you must declare a mediator to listen for a notification inside the listNotificationInterests method, you should be able to simply search your code base for the static var [SOME_NAME] and see what mediators are registered as listeners for that notification.

Or am I misunderstanding the question?
229  PureMVC Manifold / Demos and Utils / Re: Pipes - A PureMVC AS3 MultiCore Utility on: October 14, 2008, 07:36:27
hi! im finding trouble in creating the multicore mvc pipes structure in flash as3 only...
can you help me..
do you have a sample as3 sample program that we could see..with no flex..
we would really appreciate it..

I don't believe there is any demo for as3. I have managed to work it out on my own, but my project is a bit complex to just post as an example. I can try to help explain things though if you let me know where you are having trouble. I'll mention that there's actually very little difference between the Flex Multi-core pipes examples and a pure AS3 one since most of the action takes place within PMVC itself and thus has no direct ties to Flex.

The one thing you will need to build is a Module Loader, like Flex, using the Loader class. Here's mine in raw form;
:
/**
* ...
* @author Jason MacDonald (Jason.MacDonald@vfmii.com)
*/
public class ModuleLoader extends Sprite{

public static const READY:String = "READY";
private var _module:ILoadableModule;
public var _moduleVo:LoadableModuleVo;

public function ModuleLoader() {

}

public function load(moduleVo:LoadableModuleVo):void {
var loader:Loader = new Loader();
_moduleVo = moduleVo;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaded);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onIOError);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onProgress);
var loaderContext:LoaderContext = new LoaderContext(true);
loader.load(new URLRequest(moduleVo.url), loaderContext);
}

protected function removeListeners(loader:LoaderInfo):void {
loader.removeEventListener(Event.COMPLETE,onLoaded);
loader.removeEventListener(IOErrorEvent.IO_ERROR,onIOError);
loader.removeEventListener(ProgressEvent.PROGRESS,onProgress);
}

protected function onLoaded(event:Event):void {
var loaderInfo:LoaderInfo = event.target as LoaderInfo;
_module = loaderInfo.content as ILoadableModule;
removeListeners(loaderInfo);
dispatchEvent(new Event(READY));
}


protected function onIOError(event:IOErrorEvent):void {
//do something
}

protected function onProgress(event:Event):void {
//do something
}

public function get moduleVo():LoadableModuleVo {
return _moduleVo;
}

public function set moduleVo( value:LoadableModuleVo ):void {
_moduleVo = value;
}

public function get module():ILoadableModule {
return _module;
}

public function set module( value:ILoadableModule ):void {
_module = value;
}
}

LoadableModuleVo is just
:
/**
* ...
* @author Jason MacDonald (Jason.MacDonald@vfmii.com)
*/
public class LoadableModuleVo {

private var _name:String;
private var _url:String;
private var _version:String;

public function LoadableModuleVo() {

}


public function get name():String {
return _name;
}

public function set name( value:String ):void {
_name = value;
}

public function get url():String {
return _url;
}

public function set url( value:String ):void {
_url = value;
}

public function get version():String {
return _version;
}

public function set version( value:String ):void {
_version = value;
}
}

And ILoadableModule
:
/**
* The interface definition for a loadable Module.
*
* <P>The only requirement of our [dynamically] loadable
* module is that it implements this interface so we can get
         * a unique ID back from the module</P>
*/

public interface ILoadableModule
{
function getID():String;

}

I use this in conjunction with a ModuleLoaderProxy and LoadModuleCommand. Note that I do not store anything in the proxy concerning the module, it simply acts as the go-between with the loader and the responder (itself). It then dispatches a notification that the module has loaded, using the loaded swf as its body for the rest of my app to listen for and act upon. This might not be the best solution, but it seemed to me the best place for service calls like this was in a proxy, but to let the mediator store the swf once it's loaded so the proxy forgets all about it after it has sent the notification.


This is  the proxy I use
:

    public class ModuleLoaderProxy extends Proxy implements IProxy {

public static const LOAD_MODULE:String = 'mlLoadModule';
public static const UNLOAD_MODULE:String = 'mlUnloadModule';
public static const MODULE_LOADED:String = 'mlModuleLoaded';
public static const MODULE_FAILED:String = 'mlModuleFailed';
public static const MODULE_PROGRESS:String = 'mlModuleProgress';


        public static const NAME:String = "ModuleLoaderProxy";

        /** Constructor **/
        public function ModuleLoaderProxy(data:Object = null){
            super (NAME, data);
        }

public function loadModule(moduleVo:LoadableModuleVo):void {
var loader:ModuleLoader = new ModuleLoader();
loader.addEventListener(ModuleLoader.READY, onLoaded);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.load(moduleVo);
}

protected function onLoaded(event:Event):void {
var moduleLoader:ModuleLoader = event.target as ModuleLoader;
var module:ILoadableModule = moduleLoader.module;
var moduleVo:LoadableModuleVo = moduleLoader.moduleVo;

sendNotification(MODULE_LOADED, module, moduleVo.name);
removeListeners(moduleLoader);
}

protected function onIOError(event:IOErrorEvent):void {
var moduleLoader:ModuleLoader = event.target as ModuleLoader;
var module:ILoadableModule = moduleLoader.module;
sendNotification(MODULE_FAILED, module, event.text);
removeListeners(moduleLoader);
}

protected function removeListeners(moduleLoader:ModuleLoader):void {
moduleLoader.removeEventListener(ModuleLoader.READY, onLoaded);
moduleLoader.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
}

protected function onProgress(event:Event):void {
//sendNotification(MODULE_PROGRESS, module);
}
230  PureMVC Manifold / MultiCore Version / Re: Pipes Best Practice Question for Module-to-Module Communications on: October 10, 2008, 07:40:01
Good point. That makes sense. I honestly think I tend to confuse myself more than is needed when trying to get clean separation.

Thanks again.
231  PureMVC Manifold / MultiCore Version / Re: Pipes Best Practice Question for Module-to-Module Communications on: October 10, 2008, 06:18:24
Thanks Cliff. I totally get the async-token, and I may have been misleading in trying to explain my dilemma. The data is already stored in the DataService Module, in it's proxy, all it's doing is returning the VO that are requested via pipes. The dataSerivce module loads a large XML file on start-up and divvies it up into smaller VO's for distribution to the modules on request. I guess my problem is I don't want to have the DataService Module handling a tons of named pipe because they are dynamically instantiated by the Shell. I don't like the idea of the DataService module having knowledge of the actors, albiet just through named pipes. And was trying to avoid shuttling tokens around from module->shell->data and back to track who should respond to what.

I guess there's no real magic solution and I'll have to have someone aware of all the actors [modules] to direct the data traffic. Probably the Shell since it's more tied to the app itself than the modules are.

Thanks for the feed back.
232  Announcements and General Discussion / General Discussion / Re: 4-things-to-hate-about-puremvc ??? on: October 09, 2008, 01:10:20
@Jason: Give it a break! Your comment has been published without any problems whatsoever. Even though the internet does provide some kind of anonymity, do try to avoid becoming personal. It doesn't help the conversation.

Funny, I use my real name to NOT be anonymous. And you're response is to insult me using a restaurants name. I'm Scottish, not Irish. That's MAC not MC. I thought I left childish insults using name play back in grade school. Guess some people never grow up. I'm done posting on your blog, I only made a response because I see thousands of writings across tons of topics all the same, complain, bitch, moan and do nothing to help. By your own admission you'll publicly bitch about how terrible something is but use it anyway without giving one thing back to the people who worked damn hard to make it. I'm sure Cliff will appreciate that.

You say in your response that you are helping, helping people pick a framework by pointing out all it's faults. Sorry, but a user reading your blog would have to conclude that they shouldn't use ANY of them cause they all suck by your estimate and all have it wrong. It's this point that bugs me.

And before I sign off on this for good, I'm not discouraging discussion on how something can be improved, I'm all for that. I just don't like when people openly bash something and give nothing to indicate they are trying to open a discussion on the topic. How about a topic like "4 things I think need improvement in PMVC and some possible solutions". There's a discussion that both opens the table for productive brainstorming while also bring current "issues" to light for new users.

I'm done beating my head against this brick wall. Do what you want.
233  Announcements and General Discussion / Fabrication / Re: Fabrication - Simplified PureMVC multicore modules on: October 09, 2008, 06:59:10
Great news! Thanks for your hard work, it's appreciated. I can't wait to give it a go. Though it might have to wait till my next project since the one I'm doing now is under a tight deadline. :(
234  Announcements and General Discussion / General Discussion / Re: 4-things-to-hate-about-puremvc ??? on: October 08, 2008, 01:55:34
I decided to respond however my comment is "awaiting moderation", so i'll post it here in case he decides he doesn't like my comment.

JasonMacdonald Says:  Your comment is awaiting moderation.

So by your estimate, PureMVC should work with Flex and nothing else because you want to use Dependency Injection? And screw all the Flash/AS3 only users out there? Or maybe they should completely rebuild the framework into two separate branches (or 10) for accomplishing the same thing? That’s productive.

Why don’t you stop complaining about how all the frameworks out there have it wrong and BUILD YOUR OWN. Save the rest of the world from your complaining how everyone else gets it wrong and you are right. I honestly can’t stand people like you. Nothing but complaints all the while you do nothing to contribute to the end goal.

If you don’t like it, don’t use it… it’s that simple. If you like it but think it could be improved, contribute! Don’t just bash it for the sake of some blog views.
235  Announcements and General Discussion / General Discussion / Re: 4-things-to-hate-about-puremvc ??? on: October 08, 2008, 01:41:24
You could write a post about, "4 things I hate about..." on just about any framework in existence. Not a single one is perfect in everyone's eyes. If it doesn't make sense to you, don't use it. People write "reviews" like this on popular subjects simply to get eyeballs on their blog, no different than what every news stand publication in existence does, whether their views are right or not. I personally loath people that simple write how bad something is, use it any way and do nothing to contribute to improving the "perceived" deficiencies. The guys last 10 posts on his blog are nothing but bitching about things he hates... that's useful!

Basically he wants PMVC to work with Flex (dependency injection) and nothing else, guess I'd be screwed being a Flash CS3 guy if he was at the helm... glad he's not.
236  PureMVC Manifold / MultiCore Version / Pipes Best Practice Question for Module-to-Module Communications on: October 08, 2008, 12:32:53
So I've been building a rather large application using Multi-core and pipes (Pure As3, no FLex) and so far have most of the basics working (shell-> module communications, dynamic modules loading etc).

The problem I'm trying to wrap my head around is when you have a DATA module, containing most of the Model/Domain logic for the whole app, that needs to communicate with the Shell's dynamically loaded modules either one-to-one or broadcast to multiple.

I get that I can have the Shell lay down pipes between the data module and all the loaded modules, or have all the modules query up through the Shell to the Data module and then have the data flow back in the reverse order. The issue I can't figure out how to solve is when a module needs a piece of data (value objects in my case) from the Data module but that vo needs to come back to the originating module requesting it only, and not across a broadcast data pipe. This alone wouldn't be too hard I suppose, but I have the flip side where a module requests that same piece of data only this time multiple modules need to react to the returned data. Essentially I need a way to direct traffic of data without having the modules know of each other. Some kind of switch that says "hey, send this data only to me, or send it back to everyone interested". How could you accomplish this without having the Data module knowing the existence of all the modules it's connected to? I can't see how the Data Module could send a message back to only the originator without the message contaning some kind of identifier of the originator.

I'm sure this is probably somehow related to the filter messages but I haven't been able to figure out how they work yet.

My first thought was to send the modules unique ID in the message header if it should come back to it alone (thus being able to check the header of a broadcast response for it's own key), or send the request without a key it if it doesn't care who gets the data back. But that means the Data Module would need to carry around that key somehow from the time the initial request comes through its in-pipe until the time the response message is sent. And this seems rather sloppy somehow especially if it's trying to handle multiple requests at once. Things like, where would you store such a key while the commands do their thing to gather the data needed from the proxies. And how would you map that key so when the data was ready you knew what to do with it. It just starts making my head spinning trying to manage all that. There must be a simpler way.

I hope the above explanation makes sense, my brain is a bit fried right now.
237  Announcements and General Discussion / Fabrication / Re: Fabrication - Simplified PureMVC multicore modules on: October 06, 2008, 06:13:03
Any PMVC Utilities that require the MX package makes us Flash CS3 guys sad programmers :(

I'm going to have a look through the code and see what I can do to adapt it to work with Flash... though I may have to rewrite a lot to be more like your example above (extending bootstrap) to get it to work.

EDIT: Now that I've looked through the code, there's just far too much code to go through and change while trying to learn how the utility works. Nice work anyways. I'll anxiously await a CS3 version. :)
238  Announcements and General Discussion / Architecture / Re: Where to put styles of view components on: October 03, 2008, 10:25:33
Sounds pretty cool and useful. Perhaps you'll post it somewhere? I'm sure people will be interested to see it!
-=Cliff>

I'll try post something about it when I get a chance to organize it better for public use.

To give you a basic overview though I'm taking the styles loaded from StyleManager and injecting them into fl.core.UIComponent via a BaseComponenet Class which extends UIComponent. All of my components extend BaseComponent allowing me to just create my custom components the same way I would using Flash Component Framework. So I get all the functionality of the base Flash components like Focus management and component redrawing along with the ability to load styles externally or through the code as you normally would using setStyle(name, value).

The StyleManager itself is more or less a copy of Flex's StyleManager (and related classes like CSSStyleDeclaration) but adapted to the way Flash components redraw themselves instead of the way Flex does.

The XML gets parsed into StyleDeclarations Objects (basically simple style value objects of name/value pairs like bgColor:#ff0000), which in turn get loaded into the StyleManager instance [singleton] using the styleName as the key and the StyleDeclaration as the value. Later when I call StyleManager.getStyleDeclaration(styleName || className) during instantiation of a component, in BaseComponent, it returns the full StyleDeclaration Object that I then can apply to the component via setStyle().

BaseComponent simply loops through the StyleDecleration calling the parents [UIComponent ] .setStyle(name, value) method and you end up with all the styles loaded into your component. From there on everything is the same as using/creating a regular Flash Component using the default framework.

Hope that makes sense. It took me a lot of time studying both Flex and Flash component frameworks to understand the differences and try and merge the two together. But the above is the basic work flow of it.
239  Announcements and General Discussion / Architecture / Re: Yo Cliff! Why the connection between the mediator and the proxy? on: October 03, 2008, 05:58:05
Hey Cliff, that was the most important, interessting and helpful explanation I have read in this forums so far! Thank's a lot, that helped me a lot!! Yeah!!! ;D

Now I can go on building my world app ...  :D

Damn, I've been using PureMVC for almost a year now and somehow missed this post. It even made things clearer to me,and I thought I already understood most or the intricacies of PMVC. Goes to show you can always learn something new... or understand it better at least!

Thanks Cliff!
240  Announcements and General Discussion / Architecture / Re: Where to put styles of view components on: October 02, 2008, 01:20:09
thanks for the reply. However, I should've mentioned that I'm not working on a Flex application, but a pure AS3 one. There, the regular handling of styles through css stylesheets doesn't work that way. Any suggestions?
Thanks.

I was in a similar boat as you, a Flash CS3 project filled with custom components that need styles loaded from an XML file to be applied to each component at runtime.

I end up making a StyleManager Singleton that handle the application of styles to components, similar to how Flex does it. There's no PureMVC involvement. Styles are applied either to all Components instances of that type [Button] or by appyling a StyleName to a component (myButton.styleName = 'SomeStyleName').

The only PureMVC involvement is I have a Proxy that handles the loading and parsing of the XML StyleSheet that sets the values on the StyleManager on start-up.

All my visual components extend a base class that handles the interaction with the StyleManager. It looks to see if there's a styleName set, if there is it queries StyleManager for those Styles and applies them to the component (itself since each component extends the base class). If no styleName is set it looks at the ClassName and queries StyleManager using it instead. If neither is found it uses a base set of styles found in each component as defaults.

Not sure if this would work for you, but so far it's worked out nicely for me.
Pages: 1 ... 14 15 [16] 17