2 Replies Latest reply on May 4, 2006 2:58 AM by tiagoafpereira

    sending dataProvider XML to remote server

      I was wondering if it possible to send a tree dataProvider XML to a remote server using HTTPService. The problem lies in being able to obtain the dataProvider in XML form...
        • 1. Re: sending dataProvider XML to remote server
          ntsiii Level 3
          Assuming version 1.5:

          This is a bit complicated. How is your treeDataprovider getting created? I have side-stepped this problem by using pure xml as my tree dataProvider from the start.

          I set my resultformat="xml", then use the xml directly as the treeDataProvider. so I always have xml to send back to the server.

          There have been a few cases where I build the treeDataProvider manually, but I have not needed to convert that to xml.

          Unless you find a more elegant solution, I think you will have to manually recurse the treeDataProvider and build the xml string yourself.

          I have not tried it myself, but what does myTreeDP.toString() return? Probably [object Object], which won't be any help. toString() on an XML object returns the xml text string. Very useful. As I mentioned, stay with xml all the way if possible.

          • 2. sending dataProvider XML to remote server
            tiagoafpereira Level 1
            I have found a solution

            Sending the XML dataProvider is being done using a not so elegant solution, but it succeeds.
            I set the text of an invisible textArea (a similar container could work) to be tree.dataProvider:

            textArea.text = tree.dataProvider;

            and then send as part of the HTTPService request the textArea.text as the tree XML.
            tree.dataProvider.toString() did no work and I will try to find a decent solution...
            This works just fine though

            Retriving the XML and rebuilding the tree was the tricky part that only recently i got nailed. The XML is stored as is (plaintext) in a database and is returned via webservice as an xml feed.
            In Flex (1.5) i retrieve this feed using an HTTPService with resultFormat="text" (the value returned is a String) and then parse the XML using " tree.dataProvider = mx.utils.XMLUtil.createXML(feed); ". This provides the tree with an XML dataProvider.

            Previous solutions using the default resultFormat or the "xml" type though working provided the tree with an object dataProvider. In my project the tree is editable (drag and drop, reordering, etc) and this dataProvider was not compatible with such operations. The current solution enables me to always send, receive and edit pure XML.