Message Box"

From Documentation
m
Line 33: Line 33:
 
   });
 
   });
 
</source>
 
</source>
 +
 +
Notice that the invocation of <tt>show</tt> is returned immediately without waiting for user's clicks<ref>If you turned on the use of event thread, the invocation will be stalled until the user clicks a button. It is easier but threading is not cheap. For more information, please refer to [[ZK Developer's Reference/UI Patterns/Event Threads/Message Box|the Event Threads section]].</ref>.
 +
 +
There are a lot of more utilities, such as the button's order and label. Please refer to [[ZK Component Reference/Supporting Classes/Messagebox|ZK Component Reference]] and <javadoc>org.zkoss.zul.Messagebox</javadoc> for more information.
  
 
<blockquote>
 
<blockquote>

Revision as of 09:57, 13 October 2011

In additions to composing your own window for displaying a message, ZK provide a simple utility: Messagebox[1]. For example,

Messagebox.show("The file has been removed successfully.");

DrMessagebox.png

If you could specify a different icon for difference scenario, such as alerting an error:

Messagebox.show("Unable to delete the file", null, 0, Messagebox.ERROR);

DrMessagebox-error.png

Another typical use is to confirm the users for a decision, such as

Messagebox.show("Are you sure you want to remove the file?", null,
   Messagebox.YES+Messagebox.NO, Messagebox.QUESTION,
   new EventListener() {
      public void onEvent(Event event) {
          if (Messagebox.ON_YES.equals(event.getName()))
             ;//delete the file
      }
   });

Notice that the invocation of show is returned immediately without waiting for user's clicks[2].

There are a lot of more utilities, such as the button's order and label. Please refer to ZK Component Reference and Messagebox for more information.


  1. If you are using zscript, there is a shortcut called alert as follows
    <button label="Show" onClick='alert("The file has been removed successfully.")'/>
    
  2. If you turned on the use of event thread, the invocation will be stalled until the user clicks a button. It is easier but threading is not cheap. For more information, please refer to the Event Threads section.

Version History

Last Update : 2011/10/13


Version Date Content
     



Last Update : 2011/10/13

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