0

Client.showBusy - Strange Behaviour

asked 2016-05-04 11:35:12 +0800

ansancle gravatar image ansancle
317 9

I use Clients.showBusy in numerous places in my application without any trouble. I am running into a strange issue with the following button callback that tries to invoke it. When I press the load button this callback is called via a javascript function in the zul. I want to showBusy while the search is invoked in the populateZoneMessageChangeHolderByDateRange method. I put the thread.sleep to make the delay long enough to test the showBusy. I have tried it both without passing in a component to showBusy and passing one in. It doesn't make a difference. I do not get the busy dialog until Clients.clearBusy is called, and then it doesn't go away. This is strange and I can't figure out what's going on since I use the same calls in numerous other places and it works fine. Any ideas? Here is the class definition and method.

    public class DHzClimateZoneHistoryView extends GenericForwardComposer<Window> 
{........


    /**
 * 
 * Method : onLoadButtonClicked
 * @param event
 */
public void onLoadButtonClicked(Event event) throws Exception
{
    try
    {
        Clients.showBusy("Loading...");
        Thread.sleep(7000);
        populateZoneMessageChangeHolderByDateRange();
        Clients.clearBusy();
    } 
    catch (Exception e) 
    {                       
        Clients.clearBusy();
        e.fillInStackTrace();
        _logger.error(".....",e);
        throw e;
    }

}
delete flag offensive retag edit

Comments

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-05-04 13:42:31 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

updated 2016-05-26 07:26:07 +0800

You never go back to the client.
The moment you go back to the client => it's updating with show and clear at the same time. (in other words, I don't see a callback here)

Try Events.echoEvent and do your long op in the echo event.

Or maybe an even better method is to use Robert his implementation.

Please read this small talk in order to make long ops easier.

Some more explication after comment :

Well, I do explain this with some real life example : Let's say you have a client who want something done.
He has a contact with some company X.
Because the workload is high => company X will outsource it to company Y.
Now the Client doesn't want that work done anymore so he tells to company X to work on something else now.
But In order to stop company Y => company X should notify company Y to stop working.
Bring this back to the application.
The Client notifies the server he navigates to other page.
But did you implement that the server notifies that the thread has to stop?
It will not be automatic, so you need to implement this behavior or just let the thread finish it's work, what normally doesn't have to much impact on your application.

link publish delete flag offensive edit

Comments

So I implemented the Long Operation which works great. What happens to the thread if the user navigates away from the page that the thread was started on? Does it continue to completion or is it terminated?

ansancle ( 2016-05-25 15:13:59 +0800 )edit
0

answered 2016-05-04 14:49:51 +0800

ansancle gravatar image ansancle
317 9

updated 2016-05-04 14:50:16 +0800

This method is inside the ZK event loop, shouldn't the connection to the client be there allowing the show busy to happen?

link publish delete flag offensive 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
1 follower

RSS

Stats

Asked: 2016-05-04 11:35:12 +0800

Seen: 24 times

Last updated: May 26 '16

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