3 Replies Latest reply on Sep 21, 2006 11:39 AM by refactor1

    Major HTTPService Bug - Adobe pls help!

      I have finally looked into this issue enough to verify the problem and have found a few workarounds online. The bottom line is that an HTTPService getting an xml response will return different data references if and ONLY if the xml has a single child. Therefore, an application that works fine populating a datagrid bound to an HTTPService will break when the source XML goes down to a single "row" or child node. The reason is that by default Flex converts multiple children into an ArrayCollection but does NOT do so for a single child, thus breaking the references. I have coded around this but should not have to.

      Does anyone from Adobe have advice/news about this problem?
        • 1. Re: Major HTTPService Bug - Adobe pls help!
          peterent Level 2
          This is not a bug - it is working as intended. Not everyone wants a single result to be an array. You have to code for the possibility. You can always use ArrayUtil to make the result into an array. ArrayUtil will not nest one array inside of another - it only makes an array if the argument it is given is not already an array.
          • 2. Re: Major HTTPService Bug - Adobe pls help!

            I have the same problem. And there is another problem when the source XML has no row.
            A workaround (with catalog.xml in flexstore demo)
            var source:ArrayCollection;
            if (catalogConn.lastResult.catalog == null)
            // no child
            source = new ArrayCollection();
            source = (catalogConn.lastResult.catalog.product is ArrayCollection
            ? catalogConn.lastResult.catalog.product as ArrayCollection
            : new ArrayCollection(ArrayUtil.toArray(catalogConn.lastResult.catalog.product)));
            productAC = source;


            • 3. Re: Major HTTPService Bug - Adobe pls help!
              I agree with furDervish. Why would you not have a collection for a single element in the case where two elements would produce a collection? Can you please show an example of the code to deal with this problem. I'm having serious trouble detecting 1 element from none. I get null reference if there is only one child element in the xml structure.