2 Replies Latest reply on Nov 5, 2007 9:55 AM by ntsiii

    Dynamically Populating a tree in Flex from XML using HttpService - Java


      I am trying to search for a solution for my problem for the last couple of days wothout any luck.Surpisingly I wasn't able to find any thing related to "Dynamically Populating a tree in Flex from XML using HttpService - Java ". Hope you can help! Appreciate your time !

      This is the format of the XML that I get when I communicate to a Java Servlet,via HTTPService..

      <Parent id="Parent" name="Tester">
      <Child id="services" name="Services">
      <Leaf id="1" name="One"/>
      <Leaf id="2" name="Two"/>
      <Leaf id="3" name="Three"/>
      <AnotherChild id="4" name="Work">
      <AnotherLeaf id="111" name="1234"/>
      <AnotherLeaf id="222" name="abcdef"/>
      <AnotherLeaf id="333" name="xyz123"/>
      <LastChild id="ABC" name="ABC">
      <action id="q1" name="1"/>
      <action id="q2" name="2"/>
      <action id="q3" name="3"/>

      I wanted to dynamically populate the tree using this xml and wanted to be able to do particular action when clicked on item, but I wasn't suseccful. This is the code snippet that I wrote,Can you please help me ?

      <?xml version="1.0"?>

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="getDetails.send();">

      <mx:HTTPService id="getDetails"
      url=" http://localhost:8080/FlexTest"
      resultFormat="e4x" />

      ****************************************************************************************** ********************************************

      import mx.collections.XMLListCollection;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.controls.Alert;

      [Bindable]private var result:XML;

      private function dataResultHandler(event:ResultEvent):void

      var result:XML = event.result as XML


      private function dataFaultHandler(event:FaultEvent):void

      Alert.show(event.fault.message, "Could not load Data feed");


      ****************************************************************************************** ********************************************

      <mx:Tree width="100%" height="100%" id="tree1" dataProvider="{result}" labelField="@name" showRoot="true" />