2 Replies Latest reply on May 26, 2010 12:43 AM by kiran7881

    A query with respect to Cairngorm Events

    kiran7881 Level 1

      I am new to cairngorm .
      I am designing a StudentApplication using Flex with Cairngorm .
      I am struck at writing a Event class for Cairngorm .Please guide me

       

      Assume that this StudentApplication is suppourting Create , Delete , Update ,Read Operations .

       

      My question is do i need to write 4 Event classes , each representing that Operation ,

       

      Or is it possible to do in one Event class by taking 4 different Sring constants , each representing the Appropiate Action .

       

      package com.control
      {
          import com.adobe.cairngorm.control.CairngormEvent;
        
          public class CreateEvent extends CairngormEvent
          {

             
          } 
      public static const EVENT_CREATE_STUDENT : String = "EVENT_CREATE_STUDENT";
      }

       

      My question is do i need to make Create , Update , Delete , Read Events for every
      Event of my Application ??

       

      Please guide me .

       

      Thanks in advance .

        • 1. Re: A query with respect to Cairngorm Events
          BhaskerChari Level 4

          Hi Kiran,

           

          You can write all the events in a single class say StudentEvent class and perform the appropriate action according to the event type(delete,update,add..etc) but if you do so you need to process the result returned from the remote service based on the event type in command later and write your logic.

           

           

          for ex:

           

          In your command layer(StudentCommand) in the result Handler...function you need to process this way..

           

          public function result( data : Object ) : void

           

                  {

           

                      if(data != null)

           

                      {              

                              if(_eventtype == "deletestudent")

                              {

                                   // Write you logic to delete student

                              }

                              else if(_eventtype == "createstudent")

                              {

                                   // Write you logic to create student

                              }

                              else if(_eventtype == "updatestudent")

                              {

                                   // Write you logic to update student

                              }

                              else

                              {

                                   // Write you logic to read student details

                              }

           

           

                      }

           

                  }

           

          deletestudent, createstudent, updatestudent, readsrstudent are the four event types which you decalre as Static Constants in StudentEventclass.

           

          If you wanna write 4 event classes for all then also its good so that you can have seperate wrapper class for all the events.

           

           

          If you want to have customized and reduced code then use the Single event class. Its based on your requirement...

           

          Thanks,

          Bhasker Chari

          • 2. Re: A query with respect to Cairngorm Events
            kiran7881 Level 1

            Bhasker , Thanks for your time taken for explaning so nicely .

             

            Thanks again .