The
CairngormFrontController extends Cairngorm's
FrontController and adds the ability to pass in commands to
the constructor.
The object with the command definitions must have the following form:
var commands:Object = {
"myFirstEvent": "com.domain.command.MyFirstCommand",
"mySecondEvent": "com.domain.command.MySecondCommand"
};
// instantiate a front controller and pass in the commands objects
var controller:FrontController = new CairngormFrontController(commands);
...where the key in the commands object is the name of the
event that the frontcontroller will listen to and the value is the
fully qualified class name of the command that will be executed.
Notice that the constructor takes a second optional argument specifying
the package where the commands reside. By passing in this argument it is
not needed to specify fully qualified classnames for the command classes.
Only the classnames themselves need to be specified then.
var commands:Object = {
"myFirstEvent": "MyFirstCommand",
"mySecondEvent": "MySecondCommand"
};
var controller:FrontController = new CairngormFrontController(commands, "com.domain.command");
The following is the xml definition of the
controller instance:
<object id="controller" class="org.pranaframework.ioc.util.CairngormFrontController">
<constructor-arg>
<object>
<property name="myFirstEvent" value="MyFirstCommand"/>
<property name="mySecondEvent" value="MySecondCommand"/>
</object>
</constructor-arg>
<constructor-arg value="com.domain.command"/>
</object>
commandMap:Object [write-only]Implementation
public function set commandMap(value:Object):void
commandPackage:String [read-write]Implementation
public function get commandPackage():String
public function set commandPackage(value:String):void
public function CairngormFrontController(commands:Object, commandPackage:String = "")
Creates a new CairngormFrontController instance.
Parameters
| commands:Object — an object containing key/value pairs with the event names and the command classes
|
| |
| commandPackage:String (default = "") — the package where the commands reside
|
public override function addCommand(commandName:String, commandRef:Class, useWeakReference:Boolean = true):void
Adds an extra check to see if the command class implements ICommand.
Parameters
| commandName:String |
| |
| commandRef:Class |
| |
| useWeakReference:Boolean (default = true) |
protected override function executeCommand(event:CairngormEvent):voidParameters
public static function getInstance():CairngormFrontController
Returns
Prana Framework 0.5 - 2008