live data update in cached ListModel

asked 2019-01-14 10:51:28 +0800

superium gravatar image superium
17 2

I'm using a ListModel with cached Map like this : http://books.zkoss.org/zk-mvvm-book/8.0/advanced/displaying_huge_amount_of_data.html# (http://books.zkoss.org/zk-mvvm-book/8.0/advanced/displayinghugeamountofdata.html#)

paging ok. but i don't know how to add date lively.

the data was stored in a hashMap (because with paging, user may query any page ,we load it on-demand). but the traditional ListModelList (which could update data lively),use _list to store data. so I can't make it support live date update by implements ListModelList. if override the add method like this:

public boolean add(PrShowBean p) {

    boolean ret = cache.put(indexkey,data) != null;
    fireEvent(ListDataEvent.INTERVAL_ADDED, indexkey, indexkey);
    return ret;


the added data not appear in the list,but the first item in second page appears twice.

is there any way to support both load on-demand (paging) and live update ?

delete flag offensive retag edit


you can also do real time databae pagination, in mine oppinion a better way then caching some results with lesser chance of having object states not in sync with DB

chillworld ( 2019-01-15 17:57:27 +0800 )edit

Thanks for your idea.i've study some article to understand it.but it seems as a back-end tech,while i have problem with working on the ListModel associated to the UI component.

superium ( 2019-01-21 11:11:32 +0800 )edit

it's a back-end tech together with front-end implementation. Why would you cache data if you need live updates? The point is to reduce network occupation. You make now 1 big call and redo those big calls while database pagination will reduce call's to the minimum to show on your screen.

chillworld ( 2019-01-21 18:02:16 +0800 )edit

switch page will fetch new live data from your DB. (if you use spring data => check out mine github https://github.com/chillworld/customdatabasepaging_listbox)

chillworld ( 2019-01-21 18:04:02 +0800 )edit

I'll try to study your code.(i'm not using spring) i'm working on a forum like project.i cache data for a thread list,this is for paging purpose. but when user start a new thread, i need to update the thread list.

superium ( 2019-01-22 17:29:52 +0800 )edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2019-01-14 10:51:28 +0800

Seen: 9 times

Last updated: Jan 14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More