> 3) Why exactly are u looking to do?

-Have one event type 'task' that handles multiple usages
-Event usages:
     -Display all (update arrayCollection)
     -Display one in detail (update instance of a VO)
     -Add  task (add instance of VO to the arrayCollection)
     -Edit task (update database for instance of VO)
     -Delete task (remove instance of VO from db and arrayCollection)

-Try to understand if one command can be written well to handle these
situations, or if it is better to have a command for each scenario
which all tie in to the same event type

Below is some of the pieces of code I have for the 'generic command'
approach that might help for discussion.
//TaskEvent.as
package com.events {
     import com.adobe.cairngorm.control.CairngormEvent;
     import com.vo.PersonVO;
     import com.vo.TaskVO;
        
public class TaskEvent extends CairngormEvent {
        public static var TASK_ADD:String = "TaskAdd";
        public static var TASK_EDIT:String = "TaskEdit";
        public static var TASK_DELETE:String = "TaskDelete";
        
        public var User:PersonVO;
        public var Task_Update:TaskVO;
                                        
        public function TaskEvent(p_type:String, p_User:PersonVO,
p_Update:TaskVO) {
        super(p_type, false, true);                     
        User = p_User;
        Task_Update = p_Update;                 
        }
    }
}


package com.commands
{
        import com.adobe.cairngorm.commands.Command;
        import com.adobe.cairngorm.business.Responder;
        import com.adobe.cairngorm.control.CairngormEvent;
        
        import com.model.ModelLocator;
        import com.business.TaskDelegate;
        import com.events.TaskEvent;
        import com.vo.PersonVO;
        import com.vo.TaskVO;
                
        import mx.rpc.events.ResultEvent;
        import mx.rpc.events.FaultEvent;
        import mx.utils.ArrayUtil;
        import mx.collections.ArrayCollection;
        
public class TaskCommand implements Command, Responder {
public function execute(p_event:CairngormEvent):void {
     switch(p_event.type) {
        case TaskEvent.TASK_ADD:
                TaskAdd(TaskEvent(p_event).User, 
                        TaskEvent(p_event).Details);
                        break;
        case TaskEvent.TASK_DELETE:
                TaskDelete(TaskEvent(p_event).User, 
                        TaskEvent(p_event).Details);
                        break;
        }
     }
//Skipped the actual content of TaskAdd / TaskDelete functions
}


Tom's reply leads me to believe there is a way to do the equivelent -
from my coding example - of having a TaskAdd_onResult,
TaskDelete_onResult and TaskAdd_onFault, TaskDelete_onFault within the
same command rather than having to separate out. But how is not quite
clear to me.

Reply via email to