0

Live data problem with ListBox and ListModel

asked 2006-02-26 08:41:54 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3597934

By: rob_chou

I created a ListModel that has 2 columns and n rows.
I also created a ListitemRenderer.

The ListModel is based on data from inside my application. The underlying data changes (add/remove/update) every 4 seconds.

Currently, I create a ListModel (and renderer) instance and store it in the session scope (to avoid recreating it on every page/zul refresh).

In my application log, I notice lots of the following exceptions when zk is responding to the ListDataListener.onChange() event (because my data is changing every 4 seconds):

Caused by: java.lang.NullPointerException
at com.potix.zk.ui.sys.UiEngineImpl.getCurrentVisualizer(UiEngineImpl.ja
va:147)
at com.potix.zk.ui.sys.UiEngineImpl.addInvalidate(UiEngineImpl.java:163)
at com.potix.zk.ui.AbstractComponent.invalidate(AbstractComponent.java:6
73)
at com.potix.zul.html.Listcell.invalidate(Listcell.java:187)
at com.potix.zul.html.impl.LabelElement.setLabel(LabelElement.java:46)
at com.potix.zul.html.Listbox.clearItemAsUnloaded(Listbox.java:777)
at com.potix.zul.html.Listbox.syncModel(Listbox.java:753)
at com.potix.zul.html.Listbox.onListDataChange(Listbox.java:834)
at com.potix.zul.html.Listbox.access$200(Listbox.java:73)
at com.potix.zul.html.Listbox$2.onChange(Listbox.java:695)
... 22 more


delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2006-02-26 12:06:55 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3598040

By: tomyeh

How did you change your data every 4 seconds? By a timer component, by another thread, or other way?

It looks like ListModel.onChange is called not in an event listener.

link publish delete flag offensive edit

answered 2006-02-27 04:09:27 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3598949

By: nobody

another thread changes the data and notifies it's listeners.

My implementation of ListDataListener listens to the data changes and in turn calls it's listeners (ListDataListener.onChange).

Should I just forget propagating the add/delete/update events from the data source to the listmodel? Basically, create a new ListModel each time the zul page is rendered?


link publish delete flag offensive edit

answered 2006-02-27 04:13:38 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3598951

By: rob_chou

Forgot to mention (from above post), I have a standalone application that embeds a jetty web server.

The application has a background thread that generates data that changes every
4 seconds (add/delete/update).


link publish delete flag offensive edit

answered 2006-02-27 05:02:52 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3598994

By: tomyeh

Listbox will add a live-data listener to ListModel being added. It then updates itself if onChange is called.

On the other hand, you can not update any component except in an event listener.
This implies you cannot use another thread to refresh the list data as you mentioned.

Suggested way is to use the timer component to send a request for updating the live data. Then, it shall work fine because onTimer is an event.

link publish delete flag offensive edit
Your reply
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

Follow

RSS

Stats

Asked: 2006-02-26 08:41:54 +0800

Seen: 1,518 times

Last updated: Feb 27 '06

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