Use Echo Events

From Documentation
Revision as of 09:52, 2 December 2010 by Tomyeh (talk | contribs)

Prompt the User before Doing a Long Operation with Event Echoing

Event echoing is useful for implementing a long operation. HTTP is a request-and-response protocol, so the user won't see any feedback until the request has been served and responsed. Thus, if the processing of a request takes long to execute, the user has no idea if the request is being process, or he doesn't, say, click the button successfully. The user usually tends to click again to ensure it is triggered, but it only causes the server much slower to response.

The better approach is to send back some busy message to let the user know what happens, and then process the long operation[1]. It can be done easily with event echoing.

For example, assume the long operation is called doLongOperation, then:

<window id="w" width="200px" title="Test echoEvent" border="normal">
  <attribute name="onLater">
  doLongOperation(); //take long to execute
  Clients.showBusy(null, false); //done
  </attribute>
 
  <button label="Echo Event">
  <attribute name="onClick">
  Clients.showBusy("Execute...", true); //show a busy message to user
  Events.echoEvent("onLater", w, null); //echo an event back 
  </attribute>
  </button>
</window>

Version History

Last Update : 2010/12/02


Version Date Content
     



Last Update : 2010/12/02

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.


  1. Another more sophisticated approach is to start a working thread to process the long operation, while the user still can use other functionality.