Message Box

From Documentation
Revision as of 02:58, 20 January 2022 by Hawk (talk | contribs) (correct highlight (via JWB))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 : 2022/01/20

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