覆盖“处理"在 ZK [英] Override "Processing" in ZK

查看:24
本文介绍了覆盖“处理"在 ZK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?page id="p" title="Data Profiling Home" contentType="text/html;charset=UTF-8"?><zk><button label="Procesing" onClick="Clients.showBusy(null)"></button></zk>

点击按钮我看到这个:

我想覆盖处理小部件,以便我可以实现这一点.

我在 ZK 文档中搜索过,但没有找到任何帮助,有没有人之前尝试过这个或任何提示、链接或参考,这可以在 ZK 中实现吗?

解决方案

请试试

<按钮标签=忙碌"><属性名称=onClick">busyWin.doModal();div div = busyWin.getFellow("div");Clients.showBusy(div, null);</属性><window id="busyWin"visible="false" position="center"边框=正常"标题=忙碌..." xmlns:w=客户端"><属性 w:name="bind_">功能(桌面,船长,之后){this.$bind_(桌面,船长,之后);如果(this._drag)this._drag.opts.ignoredrag = true;//防止拖拽}</属性><hbox><div id="div" height="30px" width="30px" style="颜色:透明;">a</div><按钮标签=中止"><属性名称=onClick">Clients.clearBusy(div);busyWin.setMode("嵌入式");busyWin.setVisible(false);</属性></hbox></窗口></zk>

新样本

 <script type="text/javascript"><![CDATA[函数showBusy(){//显示忙掩码zAu.cmd0.showBusy('加载中...');//在忙消息下移动中止按钮jq('.z-loading')[0].appendChild(jq('$abortButton')[0]);}函数clearBusy(){//将中止按钮移回中止 div 下jq('$abortDiv')[0].appendChild(jq('$abortButton')[0]);//清除忙掩码zAu.cmd0.clearBusy(null);}]]></脚本><zscript><![CDATA[类 AbortableRunnable 实现 Runnable {布尔中止 = 假;int i = 0;公共无效运行(){而(真){//做某事我++;尝试 {线程睡眠(1000);} 捕获(异常 e){System.out.println(e);}//结束if (i == 5 || 中止)休息;}}公共无效中止(){中止 = 真;}公共 int getI() {返回我;}}AbortableRunnable ar = new AbortableRunnable();无效开始(){//开始System.out.println("开始");新线程(ar).开始();}无效中止(){//中止System.out.println("中止");ar.abort();//重启ar = new AbortableRunnable();}无效完成(){//结束System.out.println("完成");//重启ar = new AbortableRunnable();}]]></zscript><!-- abort div 保留中止按钮,在屏幕外显示 --><div id="abortDiv" style="position: absolute; left: -1000px; top: -1000px"><button id="abortButton" label="abort"><属性名称=onClick">//中止正在运行的进程中止();//停止检查定时器checkTimer.stop();//将 self 元素移回中止 div//并清除忙掩码Clients.evalJavaScript("clearBusy();");</属性>

<button label="做长的事情"><属性名称=onClick">//开始运行进程开始();//启动检查定时器checkTimer.start();//显示忙掩码并移动//忙消息下的中止按钮元素Clients.evalJavaScript("showBusy();");</属性><timer id="checkTimer" running="false" repeats="true" delay="1000"><属性名称=onTimer">//检查是否完成//类似于中止部分如果 (ar.getI() == 5) {结束();self.stop();Clients.evalJavaScript("clearBusy();");}</属性></定时器></zk>

问候,

<?page id="p" title="Data Profiling Home" contentType="text/html;charset=UTF-8"?>
    <zk>
        <button label="Procesing" onClick="Clients.showBusy(null)"></button>    
    </zk>

OnClick of button I see this :

I want to Override the Processing widget so that I can acheive this.

I have searched, in ZK documentation but din't find any help, have any one tried this earlier or any hint,link or reference, can this be acheived In ZK?

解决方案

Please try

<zk>
    <button label="busy">
        <attribute name="onClick">
            busyWin.doModal();
            Div div = busyWin.getFellow("div");
            Clients.showBusy(div, null);
        </attribute>
    </button>
    <window id="busyWin" visible="false" position="center"
        border="normal" title="busy..." xmlns:w="client">
        <attribute w:name="bind_">
            function (desktop, skipper, after) {
                this.$bind_(desktop, skipper, after);
                if (this._drag)
                    this._drag.opts.ignoredrag = true; // prevent dragging
            }
        </attribute>
        <hbox>
            <div id="div" height="30px" width="30px" style="color: transparent;">a</div>
            <button label="abort">
                <attribute name="onClick">
                    Clients.clearBusy(div);
                    busyWin.setMode("embedded");
                    busyWin.setVisible(false);
                </attribute>
            </button>
        </hbox>
    </window> 
</zk>

Edit: The new sample

    <zk>
    <script type="text/javascript"><![CDATA[
        function showBusy () {
            // show busy mask
            zAu.cmd0.showBusy('Loading...');
            // move abort button under busy message
            jq('.z-loading')[0].appendChild(jq('$abortButton')[0]);
        }
        function clearBusy () {
            // move abort button back under abort div
            jq('$abortDiv')[0].appendChild(jq('$abortButton')[0]);
            // clear busy mask
            zAu.cmd0.clearBusy(null);
        }
    ]]></script>
    <zscript><![CDATA[
        class AbortableRunnable implements Runnable {
            boolean aborted = false;
            int i = 0;
            public void run () {
                while (true) {
                    // do somoething
                    i++;
                    try {
                        Thread.sleep(1000);
                    } catch (Exception e) {
                        System.out.println(e);
                    }
                    // finish
                    if (i == 5 || aborted)
                        break;
                }
            }
            public void abort () {
                aborted = true;
            }
            public int getI () {
                return i;
            }
        }
        AbortableRunnable ar = new AbortableRunnable();

        void start () {
            // start
            System.out.println("started");
            new Thread(ar).start();
        }
        void abort () {
            // abort
            System.out.println("aborted");
            ar.abort();
            // reset
            ar = new AbortableRunnable();
        }
        void finish () {
            // finish
            System.out.println("finished");
            // reset
            ar = new AbortableRunnable();
        }
    ]]></zscript>
    <!-- abort div to keep the abort button,
        display outside the screen -->
    <div id="abortDiv" style="position: absolute; left: -1000px; top: -1000px">
        <button id="abortButton" label="abort">
            <attribute name="onClick">
                // abort the running process
                abort();
                // stop the checking timer
                checkTimer.stop();
                // move self element back to abort div
                // and clear the busy mask
                Clients.evalJavaScript("clearBusy();");
            </attribute>
        </button>
    </div>
    <button label="do something long">
        <attribute name="onClick">
            // start to run the process
            start();
            // start the checking timer
            checkTimer.start();
            // show busy mask and move
            // the element of abort button under busy message
            Clients.evalJavaScript("showBusy();");
        </attribute>
    </button>
    <timer id="checkTimer" running="false" repeats="true" delay="1000">
        <attribute name="onTimer">
            // check whether it is finished
            // similar to the abort part
            if (ar.getI() == 5) {
                finish();
                self.stop();
                Clients.evalJavaScript("clearBusy();");
            }
        </attribute>
    </timer>
</zk>

Regards,

Ben

这篇关于覆盖“处理"在 ZK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆