-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Notify not working at the time thread running.
@NotifyChange({ "editMode", "autoList" })
public class CounterThread extends Thread {
List<DataItem> autoList = new ArrayList<>();
public CounterThread(List<DataItem> autoList) {
this.autoList = autoList;
}
public void run() {
for (int i = 0; i < 10; i++) {
autoList.add(new DataItem("level:" + i, "value:" + i));
BindUtils.postNotifyChange(null, null, FolderViewModel.this, "autoList");
try {
Thread.sleep(15000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Here's error.
java.lang.IllegalStateException: Not in an execution
at org.zkoss.zk.ui.event.impl.EventQueueProviderImpl.lookup(EventQueueProviderImpl.java:43)
at org.zkoss.zkmax.ui.event.impl.EventQueueProviderImpl.lookup(EventQueueProviderImpl.java:58)
at org.zkoss.zk.ui.event.EventQueues.lookup(EventQueues.java:133)
at org.zkoss.bind.BindUtils.postNotifyChange(BindUtils.java:54)
to update the UI in a thread you need to enable server push and activate the desktop inside that thread. You'll have more information by reading Server Push
thanks a lot!
Asked: 2014-08-28 12:09:05 +0800
Seen: 31 times
Last updated: Sep 01 '14