View Full Version : Load Dynamic (constantly changing) XML Data to List in Flex
05-31-2012, 02:50 PM
I have an XML file which changes after every one minute or precisely speaking data(nodes) in the XML are modified or added. I want to Display the simple XML data in a List which is refreshed automatically after one minute to reflect the changes. I am a newbie and i have very little knowledge about Flex so please Give me some code snippet so that i could run it and get some idea.
05-31-2012, 03:23 PM
You can add a Timer object with the time span you need (let's say one minute) and get the XML again BUT you most probably face a caching problem where the XML contents will remain the same because the XML name didn't change.
There are 2 options for that. First, rename the XML (or add a parameter to its filename) but this option s valid only if you can administer the server or disable http caches in your code and cross your fingers to succeed because it's not always possible to persuade server with this.
A sample of what you need can be found here http://stackoverflow.com/questions/4633804/flex-burrito-displaying-xml-data-in-a-list-with-my-screenshot-test-code
06-01-2012, 06:13 AM
BUT you most probably face a caching problem where the XML contents will remain the same because the XML name didn't change.
I don't think caching would be an issue(I have a similar process and I haven't seen it come up yet), because the Flash player isn't going to be wasting memory on caching unused data since it uses so much memory already. I could be wrong though in that assumption and it simply hasn't been a problem yet. :)
That being said, if you did run in to that problem you can simply append the timestamp or any random characters to prevent it from being cached.
06-01-2012, 04:08 PM
The caching will not take place on the Flash player side but on the server, that's why I said he must add some parameter to the name (as you mentioned) and in most cases it's working, but not always, as some times the application server from the other side tries to undertand the parameters, resulting in a different dataset or a 'data not found' response.
I did faced this problem twice so far. In one occasion I managed to circumvent the problem by setting url request parameters to ask from the server to not use cache (and worked), but in the other occasion server just ignored my request so I was receiving the same data again and again (that's why the cross finger suggestion lol)
08-01-2012, 09:18 AM
You'll want to probably do the equivalent of an AJAX call via Flex. I don't have it in front of me but I think you can use the HttpRequest object.
You'll basically have your object set up to retrieve the xml with a result handler on it. Whenever you need to call it, do so:
and then you'll get your result via your handler:
private function myResultHandler(event:ResultEvent):void
//do your handling stuff here....
obviously if you using things like ArrayCollections for drop downs and such, life will be a lot easier for you.
Hope that was at all helpful,
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.