1 Reply Latest reply on Apr 20, 2008 2:42 AM by ab1301

    Refreshing data model in AIR

    antares84770
      This is probably one of those problems where you toil and slave for hours to find out it is something stupid, but I am at my wits end.

      I am constructing an AIR App that uses a data model to retrieve data from a php script that generates an XML string. The mxml string for the model and the grid, respectively :

      <mx:Model id="listingsDataGrid" source=" http://127.0.0.1/cmsbe/sql2xml.php"/>
      <mx:DataGrid id="dg" width="100%" height="100%" dataProvider="{listingsDataGrid.listing}" top="0" >


      I have this XML displayed in the data grid, but I am not able to make the grid refresh. I tried to have a button that forced a refresh with the following:

      <mx:Button label="refresh" click="listingsDataGrid.refresh"/>

      When I point my browser to the PHP script listed for the model source above, the desired (and refreshed) XML string is displayed, but no matter how many times I try to refresh it from within my AIR app or how many times I re-launch the project from within Flex Builder I cannot get the info to refresh. If I publish the application and re-install it on my system the grid reflects the latest XML data, but it then does not refresh again.

      There seems to be little documentation on the <mx:Model> way of doing things, and while I could probably use a URLRequest method to retrieve the XML with a little bit more power, I would like to stick with this simpler <mx:Model> method.

      It almost seems as if it is a caching problem, but I have done everything possible to force no caching with the PHP script itself, and the fact that it is updated each time when I point my browser to the PHP script seems to indicate the problem is not server-side.

      I have googled this to death with no results... any suggestions? Thanks in advance!

      If I need to post more/better info, just let me know...
        • 1. Re: Refreshing data model in AIR
          ab1301
          I don't know much about data models, but this is a common problem in flex when it comes to using httpservices. Once an httpservice with a method of get returns one result, it will not refresh. The answer with httpservice is to change the method to post, and put a dummy variable in the post request. I do not know how you would fix this when using a model, but you might try changing to httpservice. There is more about this problem in the context of httpservices over on the flex board.