ZK showBusy called before long operation, but it is showed after it
Using Zk 6.5.11CE.
In a modal window I got a button which clicked send an email. It is a long
operation, and in waiting time I want to use Clients.showBusy to block the
user to click/modify my modal window.
Here's the ZUL
<window apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('viewmodel.EventView')">
...fill the form...
<button label="SEND" onClick="@command('send')" autodisable="self" />
</window>
Here's Java EventView.java
@Command
@NotifyChange("*")
public void send() {
Clients.showBusy(winFather.getModalWin(), "Please wait...");
// ... do something ...
sendMail(); // it takes 2/3 seconds
Clients.clearBusy(winFather.getWinEvent());
}
Where winFather is the win (my home page) that called the modal window and
getModalWin() get the modal window, in which i got the showBusy problem.
Hope it is clear :)
However, i'm searching the web and found something interesting here and
here. So I got I have to use Echo Events.
For those had not clicked links:
<window id="w" width="200px" title="Test echoEvent" border="normal">
<attribute name="onLater">
doLongOperation(); //take long to execute
Clients.clearBusy(); //remove the busy message
</attribute>
<button label="Echo Event">
<attribute name="onClick">
Clients.showBusy("Execute..."); //show a busy message to user
Events.echoEvent("onLater", w, null); //echo an event back
</attribute>
</button>
</window>
Question(s):
is Echo Events the only chance to resolve the problem, or maybe I forgot
to do something to make showBusy properly works?
because I really don't want code in my zul page, how can I define the
stuff in my viewModel?
If i assign with binded value
disabled="@load('vm.busy')"
to all components I want to disable during email sending, and substitute
Clients showBusy and clearBusy with
busy = true; // Clients.showBusy(winFather.getModalWin(), "Please wait...");
...
busy = false; // Clients.clearBusy(winFather.getModalWin());
I got the same problem, the email is sending before zul components were
disabled. It seems to be a sync problem.
No comments:
Post a Comment