关于数据库数据更改的ZK UI更新

关于数据库数据更改的ZK UI更新,zk,Zk,当数据库发生更改时,如何更新UI上的数据? 我希望当我更改数据库中的记录时,我的用户界面能自动更新数据(使用一个通用的数据库查看器),就像Facebook在某人的朋友在剪贴板上发布内容时那样(不刷新)您可以使用轮询或推送 对于推送,您可以扩展选择器或计算器 并适用于你的zul public class ComposerPush extends SelectorComposer<Component> { private static final long serialVer

当数据库发生更改时,如何更新UI上的数据?
我希望当我更改数据库中的记录时,我的用户界面能自动更新数据(使用一个通用的数据库查看器),就像Facebook在某人的朋友在剪贴板上发布内容时那样(不刷新)

您可以使用轮询或推送

对于推送,您可以扩展选择器或计算器 并适用于你的zul

public class ComposerPush extends SelectorComposer<Component>  {

    private static final long serialVersionUID = 1L;
// wire components
@Wire
ZHighCharts chartComp;

// Basic Line
private SimpleExtXYModel dataChartModel = new SimpleExtXYModel();


 public void startWorker() {
            final Desktop desktop = Executions.getCurrent().getDesktop();
            if (desktop.isServerPushEnabled()) {
            } else {
                desktop.enableServerPush(true);
                if(timer != null)timer.cancel();
                timer = new Timer();
                timer.schedule(databaseCheck(), 0, 5000);
            }
        }

    private TimerTask databaseCheck() { 
            return new TimerTask() {
                @Override
                public void run() {
                    updateInfo();
                }
            };
        }

        private void updateInfo() {
            try {
                 Desktop desktop = chartComp.getDesktop();
                if(desktop == null) {
                    timer.cancel();
                    return;
                }

                Executions.activate(desktop);
                try {

                          **<your code in here>**

                } finally {
                    Executions.deactivate(desktop);
                }
            } catch (DesktopUnavailableException ex) {
                System.out.println("Desktop currently unavailable");
                timer.cancel();
            } catch (InterruptedException e) {
                System.out.println("The server push thread interrupted");
                timer.cancel();
            }


        }
公共类编写器推送扩展选择器或编写器{
私有静态最终长serialVersionUID=1L;
//电线元件
@电线
智高公司;
//基本路线
私有SimpleExtXYModel dataChartModel=新SimpleExtXYModel();
公开作废startWorker(){
最终桌面=Executions.getCurrent().getDesktop();
if(desktop.isServerPushEnabled()){
}否则{
desktop.enableServerPush(true);
if(timer!=null)timer.cancel();
定时器=新定时器();
timer.schedule(databaseCheck(),0,5000);
}
}
专用TimerTask数据库检查(){
返回新的TimerTask(){
@凌驾
公开募捐{
updateInfo();
}
};
}
私有void updateInfo(){
试一试{
Desktop Desktop=chartComp.getDesktop();
如果(桌面==null){
timer.cancel();
返回;
}
执行。激活(桌面);
试一试{
****
}最后{
执行。停用(桌面);
}
}捕获(DesktopUnavailableException ex){
System.out.println(“桌面当前不可用”);
timer.cancel();
}捕捉(中断异常e){
System.out.println(“服务器推送线程中断”);
timer.cancel();
}
}

@Tex'N'due看不到我的补充,你扩展了一个作曲家