Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
plum001 #1
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
-
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.... -
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... -
Cannot get data from RemoteObject
Verify if you have commons-collections.jar e commons-beanutils.jar in your lib path. -
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... -
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... -
ntsiii #2
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
-
plum001 #3
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
-
ntsiii #4
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
-
plum001 #5
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



Reply With Quote

