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

17.3. Event Classes

You will need an event class to retrieve the list of categories from the database and for the submission of posts.

Starting with the event for loading the categories, in the com.FlexBlog.events package create a new event class named LoadCategoriesEvent. Edit the class to match the following:

package com.FlexBlog.events
{
    import com.adobe.cairngorm.control.CairngormEvent;
    public class LoadCategoriesEvent extends CairngormEvent
    {
        public static const LOAD:String = 'loadCategoriesEvent';
        public function LoadCategoriesEvent(bubbles:Boolean=false,
cancelable:Boolean=false)
        {
            super(LOAD, bubbles, cancelable);
        }
    }
}

This event does not need to pass along any data and is simply going to trigger the corresponding command class.

Next, create the event for adding a post. In the com.FlexBlog.events package create a new event class named AddPostEvent. Edit the class to match the following:

package com.FlexBlog.events
{
    import com.FlexBlog.valueobjects.PostVO;
    import com.adobe.cairngorm.control.CairngormEvent;
    public class AddPostEvent extends CairngormEvent
    {
        public static const ADD_POST:String = 'addPostsevent'
        public var post:PostVO;
        public function AddPostEvent(post:PostVO, bubbles:Boolean=false,
cancelable:Boolean=false)
        {
            super(ADD_POST, bubbles, cancelable);
            this.post = post;
        }
    }
}

This event takes in a PostVO that will be passed to the corresponding command class.

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