Thanks Erik
 
but i do have a working solution , its just that the macromedia guys say there is a better one without using the backingObject (an object which is attached to a node in the tree)
 
thanks anyway.
 
BTW - the hole issue was about NOT writing a specific method in the client side :-)
 
Shlomi
 
 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Erik Westra
Sent: Wednesday, April 20, 2005 13:32
To: [email protected]
Subject: RE: [flexcoders] How to populate tree control from web service re sult (server side java objects)

I think that the problem u describe comes from the fast that (as far as i know) a tree can have a dataProvider wich is a XML object. The tree dataprovider is used to provider an API to modify the xml more easy.
 
In order to use a combination of arrays and objects to fill your tree u need to use a function wich uses the dataProvider API for u.
 
From the top of my head i wrote the code below. Im not sure if its bugfree, but u should get the idea. Maybe macromedia has a better solution than the one i wrote below. Its also possible to comvert your object to xml 1th but in that case the tree component will have to iterate over data structure again to do what the function below does.
 
I hope this helps :)
 
 
 
<code>
 
public function fillTree(node, dataProvider_array, folderKey_str, nodeKey_str, folderName_str, nodeName_str)
{
    for (var i = 0; i < dataProvider_array.length; i++)
    {
        var currentItem_obj:Object = dataProvider_array[i];
        var nodeName_str:String = currentItem_obj[nodeName_str];
 
        if (nodeName_str)
        {
            //its a node, not a folder
            node.addTreeNode(nodeName_str, currentItem_obj);
        } else
        {
            //its a folder
            nodeName_str = currentItem_obj[folderName_str];
            var newNode:XMLNode = node.addTreeNode(nodeName_str, currentItem_obj);
            fillTree(newNode, currentItem_obj[folderKey_str], folderKey_str, nodeKey_str, folderName_str, nodeName_str);
            fillTree(newNode, currentItem_obj[nodeKey_str], folderKey_str, nodeKey_str, folderName_str, nodeName_str);
        };
    };
};
 
fillTree(myTree.dataProvider, myInfo_array, "childFolders", "systemFiles", "folderName", "fileName");
 
</code>
 
 
Greetz Erik
 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Shlomi Cohen
Sent: woensdag 20 april 2005 10:49
To: '[email protected]'
Subject: RE: [flexcoders] How to populate tree control from web service re sult (server side java objects)

Hi Manish and Matt
 
Its not simple as you describe . even the documentation does have a bug , i've tried the code from below and the output is
[object],[object].....
 
 
let me remind you that my objects are jave objects that come from the server in SOAP and i have no idea what flex does with them , and believe me i tried and read all your documentation .
 
Manish your example is good for Tree that was built on XML and not from objects , cause in my case you would have
get [object Object],1,[object Object]
 
my Java objects are very simple they like this
 
class SystemFile {
   
    String fileName ;
    String fileGuid ;
}
 
class SystemFolder{
   
    String folderName;
    SystemFolder[] childFolders;
    SystemFile[] systemFiles;
}
 
trying to get to item.folderName didn't work also not item.fileName.
 
i didn't find any way to access my original object members besides backing object , what is wrong here ?
 
thanks Shlomi
 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Matt Chotin
Sent: Wednesday, April 20, 2005 00:54
To: [email protected]
Subject: RE: [flexcoders] How to populate tree control from web service re sult (server side java objects)

Also check out the TreeDataProvider API.  You should always use the methods specified in that API when working with either XML or Objects in a Tree or Menu.  That way you don't have to worry about backingObject which is an implementation detail purposely not documented.

 

Matt

 


From: [email protected] [mailto:[email protected]]
Sent: Tuesday, April 19, 2005 1:10 PM
To: [email protected]
Subject: Re: [flexcoders] How to populate tree control from web service re sult (server side java objects)

 

On 4/19/05, Shlomi Cohen <[EMAIL PROTECTED]> wrote:

> if i have a function that get a node like this
>  
>    function myLabelFunc(item):String {
>       
>         var type=typeof item; // always return {Object}
>         return item._???????
>        }

> how do i know which properties the variable 'item' has ?

If you're writing a labelFunction for a tree, you're expected to know
the format of the item so you can construct the label string out of
the data within the item.  For example, I have an item with properties
'name' and 'phone' (number), and I want the label to be a combination
of both:

  <mx:Tree labelFunction="makeLabel" />

   function makeLabel(item):String
   {
      return item.name + ": " + item.phone;
   }

makeLabel() is called for every node in the tree.

--
[EMAIL PROTECTED]
http://manish.revise.org/


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


Yahoo! Groups Links

Reply via email to