Difference between revisions of "Message Box"

From Documentation
(Created page with ' {{ZKDevelopersGuidePageHeader}} == The Message Box == The <tt>org.zkoss.zul.Messagebox</tt> class provides a set of utilities to show message boxes. It is typically used to ale…')
 
m
Line 1: Line 1:
 +
{{ZKDevelopersGuidePageHeader}}
  
{{ZKDevelopersGuidePageHeader}}
+
{{Old Version
 +
|url=http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/UI_Patterns/Message_Box
 +
|}}
  
 
== The Message Box ==
 
== The Message Box ==

Revision as of 08:48, 21 October 2011

Documentationessage Box
essage Box


Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


Stop.png This documentation is for an older version of ZK. For the latest one, please click here.

The Message Box

The org.zkoss.zul.Messagebox class provides a set of utilities to show message boxes. It is typically used to alert user when an error occurs, or to prompt user for an decision.

if (Messagebox.show("Remove this file?", "Remove?", Messagebox.YES | Messagebox.NO, Messagebox.QUESTION) ==  Messagebox.YES) {
 ...//remove the file
}

Since it is common to alert user for an error, a global function called alert is added for zscript. The alert function is a shortcut of the show method in the Messagebox class. In other words, The following two statements are equivalent.

alert("Wrong");
Messagebox.show("Wrong");

Notice that Messagebox is a modal window so it shares the same constraint: executable only in an event listener. Thus, the following codes will fail. Refer to the Modal Windows and Event Listeners section above for more descriptions.

<window title="Messagebox not allowed in paging loading">
    <zscript>
		//failed since show cannot be called in paging loading
		if (Messagebox.show("Redirect?", "Redirect?",
		Messagebox.YES | Messagebox.NO, Messagebox.QUESTION) == Messagebox.YES)
			Executions.sendRedirect("another.zul");
    </zscript>
</window>



Last Update : 2011/10/21

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