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

OnClick 按钮我看到了这个:

在此处输入图像描述

我想覆盖处理小部件,以便实现这一点。在此处输入图像描述

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

4

1 回答 1

2

请试试

<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>

编辑:新样本

    <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>

问候,

于 2012-08-29T01:38:34.770 回答