12 Replies Latest reply on Aug 27, 2007 3:46 PM by dimyself

    Flex caching old data - HELP

    dimyself
      Before I start, I'll say I'm VERY new to Flex! I've developed a small app in Eclipse with Flex plugin...

      My app simply uses a PHP script and calls a database query which returns xml data for Flex to display in a table. When I run the application in Flex or on my web server from a client browser, it shows a certain set of data. For example, when I insert data into the table it's querying it doesn't display this new data. It almost seems like it's not running the php and only pulling the swf from cache or something.

      This is really annoying. Clearing all my browser data doesn't do anything. I also changed my flex-config.xml and added the following config and it didn't help: <cache-mxml>false</cache-mxml>

      Any ideas??

      Thanks!
        • 1. Re: Flex caching old data - HELP
          dimyself Level 1
          Also, here's my entire mxml:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" >
          <mx:XML id="mydata" source=" http://dev/maintenance/hacks/flexrs.php"></mx:XML>
          var dNoCache:Date = new Date() ;
          params.nocache = dNoCache.getTime().toString() ;

          <mx:DataGrid id="emaillist" dataProvider="{mydata..REQUEST}" left="40" right="40" bottom="40" top="40">
          <mx:columns>
          <mx:DataGridColumn dataField="REQUEST_ID" />
          <mx:DataGridColumn dataField="CLASSIFICATION" />
          <mx:DataGridColumn dataField="SUBMITTER_EMAIL" />
          <mx:DataGridColumn dataField="SUB_DATE" />
          <mx:DataGridColumn dataField="MARKET" />
          <mx:DataGridColumn dataField="PLATFORM" />
          <mx:DataGridColumn dataField="EQUIPMENT_NAME" />
          <mx:DataGridColumn dataField="MAINT_DATE" />
          </mx:columns>
          </mx:DataGrid>
          </mx:Application>
          • 2. Re: Flex caching old data - HELP
            dimyself Level 1
            Anyone??
            • 3. Re: Flex caching old data - HELP
              peterent Level 2
              Take a look at this line:
              <mx:XML id="mydata" source=" http://dev/maintenance/hacks/flexrs.php"></mx:XML>

              The source property is meant for you to name your XML file and have it compiled INTO the SWF. This makes the XML immediately available but does not allow it to be downloaded.

              What you want to do is use HTTPService.
              • 4. Re: Flex caching old data - HELP
                dimyself Level 1
                Ok, so I changed it to HTTPService like the following and it still didn't work. I thought maybe I need to "clean" my project so I ran clean and now the bin directory is wiped out. How do I rebuild that data???

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" >

                <mx:HTTPService id="returnData" url=" http://dev/maintenance/hacks/flexrs.php"/>

                <mx:DataGrid id="emaillist" dataProvider="{returnData..REQUEST}" left="40" right="40" bottom="40" top="40">
                <mx:columns>
                <mx:DataGridColumn dataField="REQUEST_ID" />
                <mx:DataGridColumn dataField="CLASSIFICATION" />
                <mx:DataGridColumn dataField="SUBMITTER_EMAIL" />
                <mx:DataGridColumn dataField="SUB_DATE" />
                <mx:DataGridColumn dataField="MARKET" />
                <mx:DataGridColumn dataField="PLATFORM" />
                <mx:DataGridColumn dataField="EQUIPMENT_NAME" />
                <mx:DataGridColumn dataField="MAINT_DATE" />
                </mx:columns>
                </mx:DataGrid>
                </mx:Application>

                Did I add my HTTPService in correctly?
                • 5. Re: Flex caching old data - HELP
                  Level 7
                  Ok, so I changed it to HTTPService like the following and it still didn't work.
                  I thought maybe I need to "clean" my project so I ran clean and now the bin
                  directory is wiped out. How do I rebuild that data???

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*"
                  layout="absolute" >

                  <mx:HTTPService id="returnData"
                  url=" http://dev/maintenance/hacks/flexrs.php"/>

                  <mx:DataGrid id="emaillist" dataProvider="{returnData..REQUEST}" left="40"
                  right="40" bottom="40" top="40">
                  <mx:columns>
                  <mx:DataGridColumn dataField="REQUEST_ID" />
                  <mx:DataGridColumn dataField="CLASSIFICATION" />
                  <mx:DataGridColumn dataField="SUBMITTER_EMAIL" />
                  <mx:DataGridColumn dataField="SUB_DATE" />
                  <mx:DataGridColumn dataField="MARKET" />
                  <mx:DataGridColumn dataField="PLATFORM" />
                  <mx:DataGridColumn dataField="EQUIPMENT_NAME" />
                  <mx:DataGridColumn dataField="MAINT_DATE" />
                  </mx:columns>
                  </mx:DataGrid>
                  </mx:Application>

                  Did I add my HTTPService in correctly?

                  • 6. Re: Flex caching old data - HELP
                    peterent Level 2
                    Check the docs on HTTPService so you thoroughly understand how it works. You need to have either a result event handler function (which I recommend so you can easily debug and view the results being returned) or use data-binding on the lastResult property of HTTPService. To use an event handler, add result="onResultHandler(event)" to the HTTPService tag.

                    Then write the onResultHandler function which takes a single argument:

                    private function onResultHandler( event:ResultEvent ) : void { ... }

                    Inside that function event.result is your XML. It is your root-tag. Given your example, I would say you would then assign a variable to event.result..RESULT (assuming you have multiple <RESULT> elements in the XML). Use data-binding that varilable:

                    [Bindable] private var mydata:XMLList;

                    private function onResultHandler( event:ResultEvent ) : void {
                    mydata = event.result..RESULT;
                    }

                    and then bind mydata to the DataGrid's dataProvider. If this doesn't work, please provide a snippet of your XML data, including the root tag.
                    • 7. Re: Flex caching old data - HELP
                      dimyself Level 1
                      Thanks for the response! I will look into that...

                      Now I'm having another issue. Since I ran clean on just that Flex project, it got rid of everything in my 'bin' directory. Even if I try to create a new Flex project, theres nothing in the bin directory. I do have html wrapper checked in my project but it won't create the html or anything else in 'bin'. What am I missing here?? Also, when I try to run my application, it is giving me the following error: "unknown configuration variable 'compiler.fonts.cache-mxml'"

                      I've done a search for this string inside my 'Flex Builder 2 Plug-in' dir as well as inside eclipse and can't find anything!
                      • 8. Re: Flex caching old data - HELP
                        dimyself Level 1
                        Ok, nevermind. I found the cache-mxml tag and removed it. Now when I create a new project, bin is again being populated. I will try to change my HTTPService tag as you suggested and post if I have issues. Thanks alot for your help!!
                        • 9. Flex caching old data - HELP
                          dimyself Level 1
                          Ok, so I got it working within Flex. Whenever I run my flex app within Eclipse, it is running my php everytime now since I switched to HTTPService and loads the datagrid with my xml data. BUT, when I export my project and just try to run (double-click) my html, it loads my datagrid but hangs on: "Waiting on dev..." (dev is the server which houses the php). FOr some reason it hits the server just fine running my app through Eclipse, but hangs when running my exported app from the same machine. Am I missing something?
                          • 10. Re: Flex caching old data - HELP
                            dimyself Level 1
                            When I run my exported flex.swf, I get the following error:

                            [RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP"]
                            at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::faultHandler()
                            at mx.rpc::Responder/fault()
                            at mx.rpc::AsyncRequest/fault()
                            at ::DirectHTTPMessageResponder/securityErrorHandler()
                            at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                            at flash.events::EventDispatcher/dispatchEvent()
                            at flash.net::URLLoader/flash.net:URLLoader::redirectEvent()
                            • 11. Re: Flex caching old data - HELP
                              dimyself Level 1
                              I tried to create a crossdomain.xml file with my domain 'dev' and placed it on the web server that has my php. What is wrong here??
                              • 12. Re: Flex caching old data - HELP
                                dimyself Level 1
                                I think I found the problem. The php I'm hitting requires authentication. How can I add auth parameters to my Flex app so it doesn't hang when accessing a url?

                                I thought about adding a username/password onto the url in my flex app (seems kinda unsecure) in the following way:

                                http://username:password@dev/maintenance/hacks/flexrs.php

                                Are there any other ways of adding credentials into a Flex app OR can I make it so it will accept the users credentials in some way?