3 Replies Latest reply on Aug 25, 2009 2:58 PM by flex question

    Refresh custom list.

    flex question



      I have a PriorityQueue-class that extends ArrayCollection which contains a bunch of Task-objects. The priority is checked from timeLeft(), the method converts _date to seconds.


      I also got an ItemRenderer-class that extends UIComponent and contains a few labels. One label is: timeLeftLabel.text = data.timeLeft() + " left";


      The thing is that I want to refresh the list every 5 seconds or so, this can be done by using a Timer and then call PriQueue.refresh(), this seems to be the wrong approach since I don't want to refresh the whole list and since im using an ArrayCollection as a data provider, it should work - right?



        • 1. Re: Refresh custom list.
          babo_ya Level 3

          Not understanding your question.

          So, you just want to refresh any edited items?


          You could create a data object (value object) and bind the properties to the itemRenderer lablels or controls.. and if any value changes.. then update the data object.


          or.. if you want to update the whole arraycollection..


          add an CollectionEvent and when CollectionEventKind == "refresh"... update the itemRenderers...


          hope this helps,


          I could create a demo app. but, i'm not sure exactly what you are looking for.



          1 person found this helpful
          • 2. Re: Refresh custom list.
            flex question Level 1

            Thanks for your answer babo_ya!


            I will try explain this again.


            I have a Queue that contains Task-objects. The Task-object only know it's title and when to expire (Date).

            My List will output the Title + the seconds until the Task expire.


            Since I will have almost realtime-update, I would like to only refresh the visible items in the Listbox for a little performance-boost. The list might contain alot of items but only show about 10 rows at a time, is Flex smart enough to only update the visible ones?


            My biggest problem is that im not fully aware how Bindable works. As far as i know I will have to create a getter/setter for the expire-time which i'd rather not. I got a timeLeft()-method that turns the expire date into seconds from now and returns it.


            But im not sure how to trigger the onchange-event so that the List get's the updated objects.



            • 3. Re: Refresh custom list.
              Barna Biro Level 3

              If you are loading the whole data from the server at once then you should refresh the whole ArrayCollection. A better approach would be not to load the whole data from the server, instead limit the amount loaded to the number of enties you want to display. You could maybe just read the number of total elements and develop a paging system so that when the user clicks on "Page 3" then you'll load a specific limit from the server ( the data that is corresponding as position to "Page 3" ).


              I'm a bit tired so sorry if I wasn't clear but I do hope you got the idea. So, don't load the whole data if you don't want to display it all at once. Instead, make more requests to the server and load in only the pieces that you actually want to display. This way, your refresh will be redurec to a simple call that will return a limited amount of data.


              Otherwise, read the whole collection and update the entire list ( I'd do this because you might never know what other problems will arise on the way if you waste time segmenting you data on the client side somehow and then trying to figure out how to update only that segmented data with a server request ).