Infinitely scrolling list, how to update model?

Chris's Avatar

Chris

14 Jul, 2012 08:47 AM

Hello,

I have a basic setup: my model holds a list of VOs; service loads data via a "getData" function, that takes count and offset as parameters.
The Service dispatches a "loadComplete"-Event, when the data has arrived. This Event, mapped to a command, updates the list in the model.
I want to reload data, as the user scrolls a list. My Mediator catches the "scrollreached"-Event on the component, and would call "getData" with correct count and offset.

Question is - how does the LoadComplete-Command know, if he has to replace, or simply add the results to the models list?

I have some ideas in mind:
I could set the models list to length = 0, if I want new data. Then the LoadComplete-Command would always add the new data, and not replace it.
Or - in the mediator, register another command with the LoadComplete-Event, that adds the data. But that seems too much responsibility for a mediator...

I'm a bit confused :)
Thanks a lot for your help.

  1. Support Staff 1 Posted by Ondina D.F. on 16 Jul, 2012 08:17 AM

    Ondina D.F.'s Avatar

    Hi Chris,

    I would set the models list to length = 0, if I want new data. Then the LoadComplete-Command would always add the new data, and not replace it.

    Sure, if it works for you, you can do that.

    But, data paging for scrolling lists or data grids could get pretty complicated, depending on the requirements. If you are interested, you could do a research on the subject to get some inspiration.

    Some keywords:
    mx.collections.AsyncListView, paged collection, paged list, data page, lazy loading, lazy data structure, demand paging

    Some links:
    http://flexblog.faratasystems.com/2011/07/20/working-with-large-dat...

    Not actionscript:

    http://facestutorials.icefaces.org/tutorial/dataTable-JPA-tutorial....

    http://wiki.apache.org/myfaces/WorkingWithLargeTables

    HTH
    Ondina

  2. 2 Posted by Chris on 27 Jul, 2012 06:27 PM

    Chris's Avatar

    Hi Ondina,

    Thanks for your reply, I forgot a little bit about this thread :)
    The paging works fine, thanks for the links. Lazy Loading is what I do.
    The situation has changed - as I only display items which have a short lifetime (in my Application) and are never changed, I don't store them in a model anymore.
    Instead, I have created a viewmodel, which saves the state of the view with its items. This seems ok for me.

    Chris

  3. Support Staff 3 Posted by Ondina D.F. on 14 Aug, 2012 05:50 PM

    Ondina D.F.'s Avatar

    No problem:)

  4. Ondina D.F. closed this discussion on 14 Aug, 2012 05:50 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac