0 Replies Latest reply on Oct 22, 2008 8:19 AM by Merlyn_MM

    Tree control from a cfc xml return

    Merlyn_MM
      My cfc returntype is a string and it returns the following xml data. On app initialize I am sending the request. How can I build a tree from this output. Never did it before and tried the following way but didn't work .

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" initialize="myService.xmlTreeCreator.send();myService.getallcats.send();">

      <mx:WebService id="myService" useProxy="false" wsdl=" http://ipaddress/category.cfc?wsdl" showBusyCursor="true">
      <mx:operation name="getallcats" result="handleStringResult(event)" fault="Alert.show(event.fault.message)"/>
      <mx:operation resultFormat="xml" name="xmlTreeCreator" result="handleTree(event)" fault="Alert.show(event.fault.message)"/>
      </mx:WebService>

      <mx:Script>

      <![CDATA[
      import mx.collections.XMLListCollection;
      import mx.controls.Tree;

      [Bindable]
      private var treeData:XMLListCollection;


      public function handleTree(event:ResultEvent):void{
      treeData = event.result.root.node as XMLListCollection;
      }
      ]]>
      </mx:Script>

      <mx:Tree dataProvider="{treeData}" id="mytree" labelField="label" />

      <?xml version="1.0" encoding="UTF-8"?><root><node id="1" isBranch="true" label="Signature Programs"><node id="10" isBranch="true" label="Know Before You Grow"/><node id="11" isBranch="true" label="Fly High Fly Safe"/><node id="12" isBranch="true" label="Lifetime of Safety"/><node id="13" isBranch="true" label="Take A Load Off"/><node id="14" isBranch="true" label="Smart Experience Center"/><node id="15" isBranch="true" label="Demonstrations"/><node id="16" isBranch="true" label="Safety"/></node><node id="2" isBranch="true" label="Executive Visits"><node id="17" isBranch="true" label="Completed in 2008"/><node id="18" isBranch="true" label="Scheduled"/><node id="19" isBranch="true" label="Planned in 2008"/></node><node id="3" isBranch="true" label="Legislative Outreach"><node id="20" isBranch="true" label="City"/><node id="21" isBranch="true" label="Retail Providers"/><node id="22" isBranch="true" label="Fundraisers"/><node id="23" isBranch="true" label="Competition Works"/><node id="24" isBranch="true" label="Environmental Leadership"/><node id="38" isBranch="true" label="Energy"/></node></root>