[Arp] Adding commands at runtime
Nils Millahn
nils.millahn at deltabravo.com
Mon May 9 06:53:26 PDT 2005
Hi Gert-Jan,
of course essentially all commands are registered at runtime, except
that this is done by the main Application form rather than by the views
themselves.
As far as I know, the initial idea behind ARP was that only the
Application form would communicate with the Controller in this way, so
that the views don't need to be aware of how their commands are handled.
Bearing that in mind, it might be worth looking into this a bit more.
Where is the code located that loads in your forms? And does it
currently check to see whether they have finished loading? If all this
is happening in the Application form, you could add the listeners and
register the commands from there, once the form itself has loaded.
(idea: it might even be possible to handle this in a generic way - get
your forms to publish a list of events they broadcast and add listeners
and register commands dynamically using the naming conventions)
- Nils.
Gert-Jan van der Wel wrote:
> Hi all,
>
> I've been following the Arp mailinglist for a while now and it's been
> a great source of information for me. I've been playing around with
> ARP for a couple of months, but now it's getting serious :-)
>
> I've a question about the way the Commands are registered to the
> Controller. Last week i had one big fla file with all the Views in it.
> This fla was getting to big and slow, so i seperatied the Views from
> the main file and loaded them when needed. Because the Commands have
> to be added manually to the Contoller i had a problem. What i needed
> was a way to add Commands to the Controller at runtime. Currently i
> have every View register its commands to the Controller (in the onLoad
> function) in the following manner:
>
>
> ORDER VIEW
>
> // add command to controller
> controller = Controller.getInstance();
> controller.addNewEventListener( this, "saveOrder" );
> controller.addNewCommand( "saveOrderCommand", SaveOrderCommand );
>
> CONTROLLER
>
> // add new event listener
> public function addNewEventListener(
> viewRef:com.ariaware.arp.ArpForm, commandName:String ) : Void
> {
> viewRef.addEventListener ( commandName, this );
> }
>
> // add new command
> public function addNewCommand( commandName:String,
> commandRef:Function ) : Void
> {
> addCommand ( commandName, commandRef );
> }
>
> What i want to know is, is this ( Views registering its Commands to
> the Controller) a good way of adding Commands at runtime?
>
> I've searched the ARP mailinglist to check if this has been done
> before. I found some posts of Darron, but i couldn't figure out if
> this is "allowed".
>
> Cheers,
> Gert-Jan van der Wel
> Suite 75
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Arp mailing list
>Arp at ariaware.com
>http://ariaware.com/mailman/listinfo/arp_ariaware.com
>
>
More information about the Arp
mailing list