How to populate tree with result of webservice return?

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default How to populate tree with result of webservice return?

    I have one webservice I called to return list of division Id and name, and I
    need to pupolate it to a tree which tah labe is divsion name and data is
    division ID. How can I do it?

    here is the code:

    ================================================== ================
    <?xml version="1.0" encoding="utf-8"?>

    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
    initialize="getDivList();">
    <mx:Script>
    <![CDATA[
    function getDivList():Void {
    divWS.getDiv.send();
    }

    ]]>
    </mx:Script>
    <mx:WebService id="divWS" wsdl="http://localhost:8500/webApp/div.cfc?wsdl"
    showBusyCursor="true"
    fault="mx.controls.Alert.show(event.fault.faultstr ing)" />
    <mx:HBox>
    <mx:Panel>
    <mx:Tree id="divTree" width="300" height="200"
    dataProvider="{divWS.getDiv.result}" />
    </mx:Panel>
    </mx:HBox>
    </mx:Application>

    ==========================
    I know this is not going to work. But how can i use the XML object to populate
    the tree?
    Thank you so much...


    jj3001 Guest

  2. Similar Questions and Discussions

    1. Help:How to populate CFC result to a Tree?
      I have one webservice I called to return list of division Id and name, and I need to pupolate it to a tree which the display is divsion name and the...
    2. How to populate a tree component from a dataset
      Hi, Could anyone tell me how to go about getting fields from a dataset component (bound to a web service) into a tree component. Any help...
    3. DataGris won't populate from WebService call
      I can't get my datagrid to populate from my web service. My web service is a ColdFusion CFC. I get no errors but a blank datagrid. What am I doing...
    4. Re-populate form on page return
      I hope this makes sense. I have an application that allows the user to set priorities for a sales force. The page lists each client per row from a...
    5. Making PHP return SQL result to a different page
      Hi I have a Microsoft SQL database I can use (also mySQL, so if you know how to do this in mySQL that is just as useful). The database can only be...
  3. #2

    Default Re: How to populate tree with result of webservice return?

    jj3001 wrote:
    > ==========================
    > I know this is not going to work. But how can i use the XML object to populate
    > the tree?
    > Thank you so much...
    >
    Well, without seeing the format of the SOAP envelope contents, it's hard
    for me to give you a specific example of walking the data that comes
    back from your web service. However, here are some basic things to
    consider:

    1) The treeview "node" doesn't have to be called "node" in the XML. In
    fact, it can be called anything you want.

    2) There doesn't even have to be a "label" attribute on each node

    3) You don't have to shove your data into a single "data" attribute either.

    Best practices:

    a) don't nest properties in a child node- each node should contain all
    is necessary properties (attributes).
    b) All the nodes should have identical properties (attributes) for
    consistency

    Here is a robust example that proves all of these things. I define my
    XML using a hierarchical data set, but with consistent attributes. I
    told my tree control to use the labelField "firstName" for the label.
    (If I needed a compound name, I could have used labelFunction and wrote
    some actionscript to be really creative, like make it display last,
    first or something).

    Run it, look it over, and if you have a more specific question please
    post it under a new thread.

    <?xml version="1.0" encoding="utf-8"?>

    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">

    <mx:Script>
    <![CDATA[
    function changeEvt(event)
    {
    alert(event.target.selectedItem.attributes.lastNam e,
    event.target.selectedItem.attributes.employeeId, mx.controls.Alert.OK);
    }
    ]]>
    </mx:Script>


    <mx:Tree labelField="firstName" id="theTree" width="300" height="200"
    change="changeEvt(event)">
    <mx:dataProvider>
    <mx:XML>
    <employee firstName="Jasons" lastName="Weiss" employeeId="1">
    <employee firstName="Dave" lastName="Thomas" employeeId="2"/>
    <employee firstName="Nancy" lastName="Nurset" employeeId="3"/>
    </employee>
    <employee firstName="Joe" lastName="Schmo" employeeId="4">
    <employee firstName="Judy" lastName="Dargo" employeeId="5"/>
    </employee>
    </mx:XML>
    </mx:dataProvider>
    </mx:Tree>


    </mx:Application>


    HTH,

    Jason

    --
    Jason Weiss
    Cynergy Systems, Inc.
    Macromedia Flex Alliance Partner
    [url]http://www.cynergysystems.com[/url]

    Email: [email]jason.weiss@cynergysystems.com[/email]
    Office: 866-CYNERGY
    Mobile: 1.832.444.2246
    Jason R. Weiss Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139