(Java)ZK Server Push Time

Timer is an invisible component. It fires one or more org.zkoss.zk.ui.event.Event after a specified delay. Notice that the timer won’t fire any event until it is attached to a page.(ZK Demo)

Server push time sangat berpengaruh pada sebuah servlet , karena pada saat program ingin delay dan akan memproses banyak data, kita dapat menggunakan timer pada server yang kita buat , di sini timer dapat di atur dengan menggunakan second .

index.zul

<?xml version="1.0" encoding="UTF-8"?>

<!--
index.zul

{{IS_NOTE
	Purpose:
		
	Description:
		
	History:
		Mon Jun 12 21:23:35     2006, Created by tomyeh
		Fri May 01 04:36:35     2009, Modified by stera
}}IS_NOTE

Copyright (C) 2006 Potix Corporation. All Rights Reserved.

{{IS_RIGHT
}}IS_RIGHT
-->

<zk>
   ::::::: Server Push Time ::::::
    Timer is an invisible component. It fires one or more org.zkoss.zk.ui.event.Event after a specified delay. Notice that the timer won't fire any event until it is attached to a page.
    <style>.count { font-weight: bold; font-size: 16px; } .time { font-size: 16px; }</style>
    <zscript>
    int countNum = 10;
    void restart() {
        countNum = 10;
        pm.value = 0;
        timer.start();
    }
</zscript>
    <groupbox mold="3d" closable="false">
        <caption label="Timer Demo">
 
        </caption>
        <vlayout spacing="30px">
            <label id="now" sclass="time" />
            <label id="count" sclass="count" />
            <progressmeter id="pm" value="0" width="300px" />
            <hlayout>
                <button label="Start" onClick="timer.start()" width="80px" />
                <button label="Stops" onClick="timer.stop()" width="80px" />
                <button label="Restart" onClick="restart()" width="80px" />
            </hlayout>
        </vlayout>
    </groupbox>
    <timer id="timer" delay="1000" repeats="true">
        <attribute name="onTimer">
    now.setValue("Time :" + new Date().toString());
    if (countNum == 0) {
        timer.stop();
        return;
    }
    count.value = "Count : " + --countNum + "";
    pm.value = pm.value + 10;
</attribute>
    </timer>
</zk>

Selamat Mencoba..

Advertisements

Published by

jarcode

hello I am jarcode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s