Update Tree data source with RemoteObject results

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

  1. #1

    Default Update Tree data source with RemoteObject results

    I'm trying use a RemoteObject to dynamically populate a Tree Control, but
    when the data comes across the control is not updated with the results. The
    tree displays correctly if I use static data defined in the component, but
    doesn't display with dynamic data. Does anyone have some suggestions for
    getting this to work?


    Here are some examples of what I am doing:

    Sample from my AccountView MXML file:

    <mx:XML id="acctTreeData" />

    <mx:Tree id="accountTree">
    <mx: dataProvider>
    {acctTreeData}
    </mx: dataProvider>
    </mx:Tree>


    In my Java Server side Delegator class I return a simple XML String like so:

    StringBuffer buff = new StringBuffer();
    buff.append("<node label=\"account1\" balance=\"100.00\">");
    buff.append(" <node label=\"account2\" balance=\"100.00\"/>");
    buff.append(" <node label=\"account3\" balance=\"100.00\"/>");
    buff.append(" <node label=\"account4\" balance=\"100.00\"/>");
    buff.append("</node>");

    System.out.println("XML Output: " + buff.toString());

    return buff.toString();


    Then in my client side delegator object I take the results and set them to the
    Tree data object:

    public function onResult( result ) : Void {
    // Populate global trans list with results from server
    //mx.core.Application.application.accountTree.dataPr ovider = result;
    mx.core.Application.application.accountTree.acctTr eeData = result;

    }

    Any suggestions would be greatly appreciated.

    Thanks,

    Brett

    plum001 Guest

  2. Similar Questions and Discussions

    1. Ext. data source and Tree component
      Im using tree component and XMLConnector here. as far as i can see results in my tree (when testing my movie) it ouputs data thats loaded fom ext....
    2. Referencing array results returned to Flex via a RemoteObject Call
      Hi, Here's the RO result using the NetConnection Debugger. I have a function that can always read the first array element, but the others...
    3. Cannot get data from RemoteObject
      Verify if you have commons-collections.jar e commons-beanutils.jar in your lib path.
    4. Tree Component & MSSQL Source
      I'm trying to learn the Tree component and use it with data I've pulled through mssql -> PHP -> LSO and into (hopefully) the tree. All of the...
    5. Trigger to update another data source
      You can create a Linked Server on your SQL 2000 Server which connects to your OLEDB/ODBC Datasource. You will find more details in the SQL Books...
  3. #2

    Default Re: Update Tree data source with RemoteObject results

    Can you see your xml strung in the onResult function?
    Try :
    var xmlDP:XML = mx.utils.xmlUtils.createXML(result);
    mx.core.Application.application.accountTree.dataPr ovider = xmlDP;

    Tracy
    ntsiii Guest

  4. #3

    Default Re: Update Tree data source with RemoteObject results

    Yes, I can see the XML string returned from the server in the onResult method.
    I tried using the

    var xmlDP:XML = mx.utils.XMLUtils.createXML(result);
    mx.core.Application.application.accountTree.dataPr ovider = xmlDP;

    as you suggested but it still doesn't update the tree control. Maybe there
    is a problem with refreshing the Tree control during the asynchronous server
    call.

    Thanks for your above suggestion any other suggestions would be appreciated.

    Brett

    plum001 Guest

  5. #4

    Default Re: Update Tree data source with RemoteObject results

    If you have your xml string in the result handler the issue is not about async
    stuff. (You did do the createXML and assigned xmlDP to the dataProvider IN the
    result handler, right?)

    I didn't say so but you should also remove the mx:dataProvider tag from the
    accountTree.

    More questions/suggestions:
    Does ANYTHING show up in the tree?
    What does the xml string look line, exactly? In your post, you show no root
    node. Is there one?
    Why are you using that reference? is your result handler (and mx:RemoteObject
    tag) in a sub component?
    Verify that this reference is valid
    "mx.core.Application.application.accountTree." add a height or width attribute
    to the tree then check it in the result handler:
    trace(mx.core.Application.application.accountTree. height)


    ntsiii Guest

  6. #5

    Default Re: Update Tree data source with RemoteObject results

    Thanks for your help. I checked if the reference to
    "mx.core.Application.application.accountTree." was valid as you suggested.
    The variable was undefined. I was able to get the Tree to display by defining
    a global variable to share the data between components.

    What I have is a single Application.mxml file with several UI components
    defined in files like TreeView.mxml and GridView.mxml. The Application.mxml
    file then includes these files. The problem I was having is trying to
    reference a property in the TreeView.mxml component. To work around the
    problem I defined a global variable called in the Application.mxml as follows:

    public var treeList:XML;

    Then in my Command.onResult() method I set this global variable:

    var xmlResults:XML = mx.utils.XMLUtil.createXML(result);

    mx.core.Application.application.treeList = xmlResults;

    Finally, in the TreeView.mxml file I refer to the global variable as my
    dataProvider and now the tree is displayed correctly.

    I would like to avoid global variables to share data between components. Is
    there a software pattern or design that is a better method of sharing data
    between components using Flex?


    Thanks again,

    Brett

    plum001 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