ZK的server push问题

关于server push在ZK官网有很多说明,但在应用中却老是刷新不了前台组件的信息,后来看了篇帖子才豁然开朗:
http://www.zkoss.org/forum/listComment/15408:

 

 

You'll have to enable serverPush before you can use it in a thread Please change LauncherApplicationPane() like this:

_desktop = Executions.getCurrent().getDesktop();
_desktop.enableServerPush(true);

 

 

按照这种说法,前台只在最后刷新前台信息。后来才搞明白原来刷新动作是在Executions.deactivate(desktop);之后。

 

 写道
class WorkingThread extends Thread {
public void run() {
try {
try {
for (int i = 0; i <= countSteps; i++) {
int percent = i * 100 / countSteps;
Thread.sleep(1000);
Executions.activate(desktop);
curr_step.setValue("Step: " + percent);
curr_pm.setValue(percent);
Executions.deactivate(desktop);  // 必须在修改值之后刷新
System.out.println("Step: " + percent);
System.out.println(percent);
}
} finally {
Executions.deactivate(desktop);
}
} catch (DesktopUnavailableException ex) {
ex.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
 

 

 

你可能感兴趣的:(ZK)