6 Replies Latest reply on Jun 4, 2010 4:59 AM by mmlukas

    List refresh

    mmlukas

      Hello,

      I cannot refresh list based on xml. I have following code:

       

      [Bindable]
      private var uploadedfiles:ArrayCollection = new ArrayCollection();

       

      <mx:HTTPService method="get" url="movieList.xml" id="filmXml" result="onGetMovies(event)"/>

       

      public function onGetMovies(event:ResultEvent):void {
                      var First:String = event.result.uploadedfiles.film[0].lokalizacjaFilmu.toString();
                      uploadedfiles = event.result.uploadedfiles.film;
                       videoListContainer.selectedIndex = -1;
                  }  

       

      <mx:List verticalScrollPolicy="on" width="301" height="372" id="videoListContainer" dataProvider="{uploadedfiles}" change="changePreview(event)" itemRenderer="thumb2" right="10" bottom="312" />

       

      and when xml file had changed videoListContainer is not changing. How can I force it to refresh this list?

       

      thanks

      Lukasz

        • 1. Re: List refresh
          BhaskerChari Level 4

          Hi Lukasz,

          Try to use the below resultHandler function and check once...

           

          public function onGetMovies(event:ResultEvent):void {
                          var First:String = event.result.uploadedfiles.film[0].lokalizacjaFilmu.toString();

                          if(uploadedfiles)   

                          {
                              uploadedfiles.removeAll();

                              uploadedfiles.refresh();

                          }
                          uploadedfiles = event.result.uploadedfiles.film;
                          videoListContainer.selectedIndex = -1;
                      }

           

          Please test it if this issue still exists please let me know.

           

           

          If this post answers your question or helps, please kindly mark it as such.


          Thanks,

          Bhasker Chari

          • 2. Re: List refresh
            mmlukas Level 1

            thanks for answer. I have noticed that removeAll() works fine, because my list is dissapearing, but refresh() doesn't load new xml file but old one. Any idea?

             

            Lukasz

             

             

            EDIT: it seems that it is problem with browser cache. Any idea how to force it to load xml from server not from cache?

            • 3. Re: List refresh
              BhaskerChari Level 4

              Hi,

               

              There shouldn't be any problem with the browser cache ...here it is now where realted with this problem...since you are clearing all the data from the list and binding the new results.

               

              I think there is some problem with the backend data itself...try to debug by putting a break point at the resultHandler function and try to check the data. Whether the new results are coming or the same old data is coming..?

               

              Please let me know if you still have a problem..

               

              If this post answers your question or helps, please kindly mark it as such.


              Thanks,

              Bhasker Chari

              • 4. Re: List refresh
                mmlukas Level 1

                I have made some test. I've got 2 functions:

                 

                private function refresh():void {

                       uploadedfiles.refresh();

                }

                 

                 

                private function remove():void {

                       uploadedfiles.removeAll();

                }               

                 

                And 2 buttons which are running those functions.

                 

                Test no. 1. When I press button Remove all list disappear. After I click Refresh button all list appears but without changes which were made in xml.

                Test no. 2. When I press button Remove all list disappear. I cleared firefox's cache. After I click Refresh button all list appears with changes which I made in xml file.

                 

                Any idea?

                Thank you.

                Lukasz

                • 5. Re: List refresh
                  BhaskerChari Level 4

                  Hi Lukasz,

                   

                  How do you load the xml...Whether you generate the xml programatically in backend code or else you are loading the static xml file that resides on the server.

                   

                  I dont think the problem you mentioned should occur because of Browser cache.

                   

                   

                  Thanks,

                  Bhasker Chari

                  • 6. Re: List refresh
                    mmlukas Level 1

                    Here is the all code related with my xml :

                     

                    In creationComplete = filmXml.send();

                     

                    <mx:HTTPService method="post" url="movieList.xml" id="filmXml" result="onGetMovies(event)"/>

                     

                    public function onGetMovies(event:ResultEvent):void {

                                     var First:String = event.result.uploadedfiles.film[0].lokalizacjaFilmu.toString();

                                     uploadedfiles = event.result.uploadedfiles.film;

                                        videoListContainer.selectedIndex = -1;

                                }

                     

                    <mx:List verticalScrollPolicy="on" width="301" height="372" id="videoListContainer" dataProvider="" change="changePreview(event)" itemRenderer="thumb2" right="10" bottom="312" />

                     

                    On thumb2.mxml:

                     

                    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" height="50" verticalScrollPolicy="off" horizontalScrollPolicy="off">

                     

                    <mx:Image source="{'obr/'data.nazwaFilmu'.jpg'}" width="100" height="50" left="10" top="0" />

                    <mx:Label text="{data.nazwaFilmu}" fontWeight="bold" top="10" left="100" fontSize="10" />

                     

                    </mx:Canvas>

                     

                     

                    That’s it.

                     

                    Lukasz

                     

                     

                     

                    EDIT: I have found solution but it works only in FireFox. I wrote function:

                     

                    private function refresh():void {
                              filmXml.send()+new Date().getTime();
                              uploadedfiles.refresh();

                    }

                     

                    and I used setTimeout(refresh,60000); to refresh list after 1 minute after file upload. It works under FF but I do not know why doesn't work under IE.

                    any idea?

                    thanks,