0

Screen lock how to?

asked 2011-10-10 10:45:00 +0800

andreasboos gravatar image andreasboos
105 3

Hi everybody.

I have some more lengthy processing in certain parts of the system. To do so would "lock" the screen and not allow users to interfere in the process.

When the button is pressed, the screen appears only "processing ..." (ZK default behavior), my message does not appear.

I tried to implement EventInterceptor, doing a combination of methods beforeProcessEvent and afterProcessEvent, but when an error / exception occurs, the afterProcessEvent method is not called and the screen still "locked".

Is there any other alternative to solve this kind of question?


What's wrong with this code?

<window height="100%" width="100%">
    <button label="btn1">
        <attribute name="onClick">
            <![CDATA[
                Clients.evalJavaScript("zUtl.progressbox('myProgressbox', 'lock my window', true);");
                
                // some long operation
                String t = "";
                for (int x = 0; x < 25000; x++) {
                        t += x;
                }

                // after long operation... unlock
                Clients.evalJavaScript("zUtl.destroyProgressbox('myProgressbox');");
            ]]>
        </attribute>
    </button>
</window>


EventInterceptor implementation

   @Override
    public Event beforeProcessEvent(final Event event) {
        Clients.evalJavaScript("zUtl.progressbox('myProgressbox', 'Aguarde, processamento em execução...', true);");
        return event;
    }

    @Override
    public void afterProcessEvent(final Event event) {
        Clients.evalJavaScript("zUtl.destroyProgressbox('myProgressbox');");
    }



Thanks

delete flag offensive retag edit

1 Reply

Sort by » oldest newest

answered 2011-10-10 19:54:52 +0800

RichardL gravatar image RichardL
768 4

You could just use Clients.showBusy with Events.echoEvent, like this:

<window id="w" width="200px" title="Test echoEvent" border="normal">
  <attribute name="onLater"><![CDATA[
                String t = "";
                for (int x = 0; x < 25000; x++) {
                        t += x;
                }
  Clients.clearBusy();
  ]]></attribute>
  <button label="Echo Event">
  <attribute name="onClick">
  Clients.showBusy("My custom message..."); 
  Events.echoEvent("onLater", w, null); 
  </attribute>
  </button>
</window>

link publish delete flag offensive edit
Your reply
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: 2011-10-10 10:45:00 +0800

Seen: 196 times

Last updated: Oct 10 '11

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