1 Reply Latest reply on May 7, 2008 9:06 PM by atta707

    Populating an ArrayCollection from HttpService

    ericw8
      I am using the following variable:

      [Bindable]
      public var userDisp:ArrayCollection;

      That is being populated by:
      <mx:HTTPService id="classUserlist" url="{' http://' + servername + ':' + serverport + '/basicskills/classUserListXml.do;jsessionid=' +sessionId }" result="studentDataHdlr(event)" />

      private function studentDataHdlr(event:ResultEvent):void{

      if (event.result.userlist != null) {
      userDisp= event.result.userlist.user as ArrayCollection;
      Alert.show("LENGTH:" + userDisp.length, "", Alert.OK , this, null, null, Alert.OK);



      When the XML has more than one <user> As in the following example:
      The ArrayCollection is populated properly:

      <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
      - <userlist>
      - <user>
      <firstname>Trent</firstname>
      <lastname>Reznor</lastname>
      <username>treznor</username>
      <password>ninnin</password>
      <userId>10</userId>
      <fullname>Reznor, Trent</fullname>
      </user>
      - <user>
      <firstname>test2</firstname>
      <lastname>test2</lastname>
      <username>test2</username>
      <password>test2</password>
      <userId>11</userId>
      <fullname>test2, test2</fullname>
      </user>
      </userlist>


      When there is only one user <user> the ArrayCollection does not populate:
      <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
      - <userlist>
      - <user>
      <firstname>Mark</firstname>
      <lastname>Slaughter</lastname>
      <username>mslaughter</username>
      <password>cheese</password>
      <userId>12</userId>
      <fullname>Slaughter, Mark</fullname>
      </user>
      </userlist>


      This happens with all of my arrayCollections, Am I missing something? I cannot figure out what is going on.


      Thank you in advance.