Event Reuse

There are times where you need one event to perform the behavior of another event you already have. In this case you have two choices: One, called context.dispatchEvent from your event handler and throw the new GEMVC Event or two, inherit from a base event, overriding the behavior where necessary. While case one is probably the cleaner way in terms of decoupling and is what is used when you want a higher level controller to handle a portion of an event a lower controller is handling, sometimes due to asynchronous nature of Flex you need to perform an action immediately before do anything else. In this case you just need to inherit the event you want to share and override its handleEvent method or any other methods it may have. You can then substitute your own handlers if the you make service layer calls. Since it is impossible to guess at what events someone may want to extend it is a good idea to code your GEMVC Events in such as way as they can be easily extended. This means that your variables and methods should be in the protected scope and your constructor should be designed to accept any event type string. The following code snippet shows how to set up your constructor:

public class ResetSelectedNodeEvent extends Event implements MVCEvent

{

public static const RESET_SELECTED_NODE:String = "RESETSELECTEDNODE";

protected var _pane:String;

protected var globalApp:MELApplication = MELApplication(Application.application);

protected var model:MELModel = MELModel(MELApplication(Application.application).model);

public function ResetSelectedNodeEvent(pane:String='',type:String=RESET_SELECTED_NODE):void

{

super(type, true, false);

_pane = pane;

}

By adding a type parameter, an extended event can supply its own event identifier but since it is optional, users of the base event do not have to change anything.

GEMVC 1.0.1 released

GEMVC has been updated with support for encapsulating Flex Producer and Consumer tags within the service layer like the remoting tag. It doesn't really add any functionality beyond what the tags themselves provide but does make it consistent and allow you to specify the connection information in a messaging.xml configuration file. See the updated documentation for more information.

New Versioning

Due to some additional features, the versions will now be:

1.0.5 - Support for messaging services that use the Consumer and Producer tags (this is actually in subversion now I just have not officially released it and updated the docs)

1.1 - What was the 1.0.5 release

1.5 - What was the 1.1 release

When to use nested controllers

A user asked me when they should create a sub-controller for a nested component instead of putting it all in the main controller. There is no hard and fast rule only two guidelines. 1) It is nice to use a sub-controller to modularize your code and place it along with the component in its own directory. 2) If your events do not need access to anything outside the component they are thrown from (other than the model) then use a controller for that component (the context passed to your event handlers will be that component). If you were to place them in the main controller not only would it clutter it up but since the handler context will now be the main component you will have to use dot notation to dig down into the component you need to deal with- sometimes necessary but never desirable.

GEMVC 1.0.5 coming soon

Before I implement the solicited 1.1 features I have decided to make some modifications to allow mxml tags to be used instead of actionscript if so desired. Primarily, this will affect the controller (but it may end up elsewhere as well). For example, you will be able to register for your events via mxml like . Please stay tuned.

GEMVC tutorial/example added

User Gabe Iverson has graciously created a small powerpoint presentation that shows in more detail a sample GEMVC application. It is available in the docs directory of the download. Thanks Gabe!

Solicitation of Features for 1.1 Release

In preparation for the 1.1 Release I would like to solicit inputs for features that you would like to see (depending upon the request some may be pushed to further releases).

Currently I am looking at 4 main features: 1) Pluggable Controllers, 2) Hierarchical Controllers, 3) Better Decoupling of Views, and 4) Factories for event and controller creation.

[More]

GEMVC Version 1.0 Released

The 1.0 release of the Good Enough MVC is available via subversion. The trunk contains the current code along with a batch file to generate the asdocs (at some point I will have a shell script as well). A pdf guide is available under the docs directory. Under releases you can get the pre-built swc along with the documentation.

BlogCFC was created by Raymond Camden. This blog is running version 5.5.006.