1 Reply Latest reply on Oct 16, 2009 11:51 AM by netnerd85

    HTTPService and ArrayCollection issues

    netnerd85

      Hey all,

       

      I have a datagrid display a list of businesses, when you click on a business its details come up then you click "view notes". The notes populate another datagrid, but only if there is two or more notes. It will not display one note, only once there is two.


      The notes.xml.php file works perfectly fine. I dont understand why it wont show one note, only more than one, what on earth could be wrong. I spent over an hour and a half on this code, then I added another record into the DB to find this error. It makes no sense to me, please help!

       

      Some core code

      [Bindable] private var allContactLogs:ArrayCollection = new ArrayCollection;

       

      private function initAllContactLogs():void
      {
          currentState = 'viewAllContactLogs';
          allContactLogs = new ArrayCollection;
         
          gateway.url = 'http://localhost/project/notes.xml.php';
          gateway.request = {"bid":businessDetails.business_id};
          gateway.method = 'get';
          gateway.send();
          gateway.addEventListener(ResultEvent.RESULT, viewAllNotes);
          gateway.addEventListener(FaultEvent.FAULT, faultHandler);
      }

       

      private function viewAllNotes(e:ResultEvent):void
      {
          allContactLogs = e.result.contact_logs.contact_log;
      }

       

                      <mx:DataGrid id="contactLogs" dataProvider="{allContactLogs}" change="viewContactLogDetails(event)" left="418" top="40" height="143" width="400">
                          <mx:columns>
                              <mx:DataGridColumn headerText="Date Contacted" dataField="date_contacted"/>
                          </mx:columns>
                      </mx:DataGrid>

        • 1. Re: HTTPService and ArrayCollection issues
          netnerd85 Level 1

          Found out by this post, http://forums.adobe.com/message/2130885 that it is a BUG

           

          Fixed my code doing the following

           

          import mx.utils.ArrayUtil;
          import mx.utils.ObjectProxy;

           

          private function viewAllContactLogs(e:ResultEvent):void
          {
              if(e.result.contact_logs.contact_log is ArrayCollection){
                  allContactLogs = e.result.contact_logs.contact_log;
              }else if(e.result.contact_logs.contact_log is ObjectProxy){
                  allContactLogs = new ArrayCollection(ArrayUtil.toArray(e.result.contact_logs.contact_log));
              }
          }

           

          Maybe it will be fixed one day? Flex is the most annoying thing I have put effort into learning. Not happy jan, not happy at all!