0 Replies Latest reply on Sep 25, 2010 3:04 PM by njtorrance

    Why this strange CallResponder behavior?

    njtorrance

      Perhaps someone can help me figure out why calling "catSelectionChangeHandler()" below sets "restaurants" (the ArrayCollection) equal to "selectedRestaurants". I am confused because "restaurants" is only supposed to be affected by the "getAllRESTAURANTResultHandler()" method.

       

      Can you see where the problem is, or is it somewhere in the code I haven't included?

       

       

              private function initApp():void
              {
                  getAllRESTAURANTResult.token = rESTAURANTService.getAllRESTAURANT();
              }


              // The list of all the restaurants
              public var restaurants:ArrayCollection;
             
              // The restaurants matching the user's selection
              [Bindable]
              private var selectedRestaurants:ArrayCollection = new ArrayCollection();

       

              private function getAllRESTAURANTResultHandler(event:ResultEvent):void

              {

                    restaurants = event.result as ArrayCollection;
                    selectedRestaurants = restaurants;
                    // add stuff to a datagrid here
               }

       

       

              private function catSelectionChangeHandler(selectedCategories:ArrayCollection):void

              {
                      getRESTAURANTSByCATEGORIESResult.token = rESTAURANTService.getRESTAURANTSByCATEGORIES(selectedCategories.toString());
              }
             
              private function getRestaurantsByCategoriesResultHandler(event:ResultEvent):void

              {
                      selectedRestaurants.source = ArrayUtil.toArray(event.result.source);
              }

       

       

      Here are the relevant MXML declarations:

      <restaurantservice:RESTAURANTService id="rESTAURANTService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
          <mx:CallResponder id="getAllRESTAURANTResult" result="getAllRESTAURANTResultHandler(event)"/>
          <mx:CallResponder id="getRESTAURANTSByCATEGORIESResult" result="getRestaurantsByCategoriesResultHandler(event)"/>