2 Replies Latest reply on Nov 17, 2009 2:17 PM by TerrySwDev

    Event to Command Issues

    TerrySwDev

      Flex Version: 3

      Cairngorm Version: 2.2.1

       

      I am working on a project that retreives data from a remote service but I current have the delegate stubbed to call the result function in the command with hardcoded data. When I dispatch the event that calls a command, nothing appears to happen. So I added a text area to my view and used data binding so that its content is stored in a String within the model and update that String with debug messages in various functions throughtout the application. (Alert.show crashes my application for some reason??)

       

      The debug messages that I put in before and after the event is dispatched appear correctly as do other messages throughout the application. However, the ones inside of the command do not show up. This leads me to believe that the command is not being called at all. But just to verify that I added in an infinite while loop into the execute function of the command and the application hung. Removed it and the application worked as before but the debug message inside of the execute function still didn't show up. Apparently the command is running but it cannot talk to the model... ???

       

      I'm stumped on this one so any help would be greatly appreciated.

       

      public class GetDataSetEvent extends CairngormEvent
          {
              public static var EVENT_GET_DATA_SET:String = "getDataSet";
             
              public function GetDataSetEvent()
              {
                  super(EVENT_GET_DATA_SET);
              }
             
              override public function clone():Event
              {
                  return new GetDataSetEvent();
              }   
             
          }

       

      public class ArenController extends FrontController
          {
              public function ArenController()
              {
                  initCommands();
              }
             
              public function initCommands():void
              {
                  addCommand( GetDataSetEvent.EVENT_GET_DATA_SET, GetDataSetCommand );
              }
             
          }

       

      public class GetDataSetCommand implements ICommand, IResponder
          {
              public function GetDataSetCommand()
              {
                 
              }

       

              public function execute( event:CairngormEvent ):void
              {
                  var model:ArenModelLocator = ArenModelLocator.getInstance();
                  model.debugMessage += "GetDataSetCommand: execute()";


                  var delegate:DataSetDelegate = new DataSetDelegate( this );
                  delegate.getDataSet();
              }
             
              public function result( data:Object ):void
              {
                  var dataset:DataSetVO = DataSetVO( data.result );
                  var model:ArenModelLocator = ArenModelLocator.getInstance();
                 
                  model.debugMessage += "GetDataSetCommand: result()";
              }

           }

       

      public class DataSetDelegate
          {
             
              private var responder:IResponder;
              private var service:Object;
             
              public function DataSetDelegate( responder:IResponder )
              {
                  this.service = ServiceLocator.getInstance().getRemoteObject( "dataSetService" );
                  this.responder = responder;
              }
             
              public function getDataSet():void
              {

                  // STUB
                  //var call:Object = service.getGeospatialData();
                  //call.addResponder( responder );

       

                  var dataset:DataSetVO = new DataSetVO();
                 
                  dataset.users = fakeUsers(); // loads fake hard-coded user data
                 
                  responder.result( { result: dataset } );
              }

      }