0

How can I direct ZK to display the "Processing..." message while handling an ON_CHANGING event?

asked 2013-04-14 15:57:39 +0800

eli gravatar image eli
39

Hello. My ZK 6.0.1 application shows a nice "Processing..." popup with spin-wheel when handling most events such as Events.ONCHANGE. But for spinners and double spinners I prefer to listen to ONCHANGING in order to give the user instant satisfaction. Sometimes the processing for ONCHANGING can take several seconds. I know this is bad but it can't be helped. Therefore I would like to have ZK show the "Processing..." popup during handling of ONCHANGING. But ZK does not not do it, I suppose b/c ON_CHANGING should be handled promptly. How can I override this behavior?

THANKS

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-04-15 09:51:34 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

updated 2013-04-15 12:47:17 +0800

Inspired by EventQueue javadoc and its subscribe example: hope it's what you were looking for.

    public class ShowBusyController extends GenericForwardComposer {

    @SuppressWarnings("unchecked")
    public void onSpinnerChanging(ForwardEvent event) {
        if (!desktop.isServerPushEnabled()) {
            desktop.enableServerPush(true);
        }

        final EventListener el = this;
        Clients.showBusy("wait a bit...");
        Thread bgThread = new Thread() {
            public void run() {
                try {
                    this.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                String result = "hello world!";
                Executions.schedule(desktop, el, new Event("onResultsAvailable", null, result));
            }
        };
        bgThread.start();
    }

    public void onResultsAvailable(Event event) {
        String result = (String) event.getData();
        System.out.println(result);
        Clients.clearBusy();
        desktop.enableServerPush(false);
    }
}

applied to

    <zk>
    <window title="long operation" border="normal" apply="tests.showbusy.ShowBusyController">
        <spinner forward="onChanging=onSpinnerChanging" />
    </window>
</zk>

Giovanni

link publish delete flag offensive edit

Comments

I appreciate this. ZK's EventQueue is nice. I use it in other situations. But I'm not seeing how it helps here. Still, much obliged and wish you well Giovanni.

eli ( 2013-04-16 02:50:15 +0800 )edit

Whoops sorry I forgot to edit the first sentence after I changed the code snippet. Anyway the code is consistent and it works... ;P

gganassin ( 2013-04-16 06:32:50 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2013-04-14 15:57:39 +0800

Seen: 28 times

Last updated: Apr 15 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More