O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.4. How Do You Use It?

In order for the FrontController class to be able to capture dispatched Cairngorm events, there needs to be an instance of it in the application, normally in the main application file.

To include the FrontController class you created, create a namespace in the main application tag pointing to the location where you created the class. Then simply add an instance of it to the main application, as in the following:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlsn:business="com.cairngormexample.business.*">
  <business:CairngormExampleController id="controller"/>
</mx:Application>

Once you have this instance in the application, you then need to register your event-command pairings in the FrontController class that you created. You do this by using the addCommand function, as can be seen in the ShopController class from the Cairngorm store application:

package com.adobe.cairngorm.samples.store.control { import com.adobe.cairngorm.control.FrontController; import com.adobe.cairngorm.samples.store.command.* import com.adobe.cairngorm.samples.store.event.UpdateShoppingCartEvent; import com.adobe.cairngorm.samples.store.event.FilterProductsEvent; import com.adobe.cairngorm.samples.store.event.GetProductsEvent;; import com.adobe.cairngorm.samples.store.event.SortProductsEvent; import com.adobe.cairngorm.samples.store.event.ValidateOrderEvent; import com.adobe.cairngorm.samples.store.event.ValidateCreditCardEvent; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required