Class Messagebox
You don't create Messagebox directly. Rather, use show(java.lang.String, java.lang.String, org.zkoss.zul.Messagebox.Button[], java.lang.String[], java.lang.String, org.zkoss.zul.Messagebox.Button, org.zkoss.zk.ui.event.EventListener<org.zkoss.zul.Messagebox.ClickEvent>, java.util.Map<java.lang.String, java.lang.String>).
A non-XUL extension.
- Author:
- tomyeh
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe button types.static classThe event that will be received by the listener when the user clicks a button. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA Abort button.static final intA Cancel button.static final StringA symbol consisting of a white X in a circle with a red background.static final StringA symbol consisting of an exclamation point in a triangle with a yellow backgroundstatic final intA IGNORE button.static final StringA symbol of a lower case letter i in a circle.static final intA No button.static final StringContains no symbols.static final intA OK button.static final StringThe event to indicate the Abort button being clicked.static final StringThe event to indicate the Cancel button being clicked.static final StringThe event to indicate the Ignore button being clicked.static final StringThe event to indicate the No button being clicked.static final StringThe event to indicate the OK button being clicked.static final StringThe event to indicate the RETRY button being clicked.static final StringThe event to indicate the Yes button being clicked.static final StringA symbol consisting of a question mark in a circle.static final intA Retry button.static final intA Yes button. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns the template used to create the message dialog.static voidsetTemplate(String uri) Sets the template used to create the message dialog.static intShows a message box by specifying a message code, and returns what button is pressed.static intShows a message box by specifying a message code, and returns what button is pressed.static intshow(int messageCode, int titleCode, int buttons, String icon, int focus, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box by specifying a message code, and returns what button is pressed.static intShows a message box by specifying a message code, and returns what button is pressed.static intShows a message box by specifying a message code, and returns what button is pressed.static intshow(int messageCode, Object[] args, int titleCode, int buttons, String icon, int focus, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box by specifying a message code, and returns what button is pressed.static intShows a message box by specifying a message code, and returns what button is pressed.static intShows a message box by specifying a message code, and returns what button is pressed.static intshow(int messageCode, Object arg, int titleCode, int buttons, String icon, int focus, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box by specifying a message code, and returns what button is pressed.static intShows a message box and returns what button is pressed.static intShows a message box and returns what button is pressed.static intShows a message box and returns what button is pressed.static intshow(String message, String title, int buttons, String icon, int focus, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box and returns what button is pressed.static intshow(String message, String title, int buttons, String icon, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box and returns what button is pressed.static Messagebox.Buttonshow(String message, String title, Messagebox.Button[] buttons, String[] btnLabels, String icon, Messagebox.Button focus, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener) Shows a message box and returns what button is pressed.static Messagebox.Buttonshow(String message, String title, Messagebox.Button[] buttons, String[] btnLabels, String icon, Messagebox.Button focus, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener, Map<String, String> params) Shows a message box and returns what button is pressed.static Messagebox.Buttonshow(String message, String title, Messagebox.Button[] buttons, String icon, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener) Shows a message box and returns what button is pressed.static Messagebox.Buttonshow(String message, String title, Messagebox.Button[] buttons, String icon, Messagebox.Button focus, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener) Shows a message box and returns what button is pressed.static Messagebox.Buttonshow(String message, Messagebox.Button[] buttons, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener) Shows a message box and returns what button is pressed.
-
Field Details
-
QUESTION
A symbol consisting of a question mark in a circle.Since 3.5.0, they are actually style class names to display the icon.
- See Also:
-
EXCLAMATION
A symbol consisting of an exclamation point in a triangle with a yellow backgroundSince 3.5.0, they are actually style class names to display the icon.
- See Also:
-
INFORMATION
A symbol of a lower case letter i in a circle.Since 3.5.0, they are actually style class names to display the icon.
- See Also:
-
ERROR
A symbol consisting of a white X in a circle with a red background.Since 3.5.0, they are actually style class names to display the icon.
- See Also:
-
NONE
Contains no symbols. -
OK
public static final int OKA OK button.- See Also:
-
CANCEL
public static final int CANCELA Cancel button.- See Also:
-
YES
public static final int YESA Yes button.- See Also:
-
NO
public static final int NOA No button.- See Also:
-
ABORT
public static final int ABORTA Abort button.- See Also:
-
RETRY
public static final int RETRYA Retry button.- See Also:
-
IGNORE
public static final int IGNOREA IGNORE button.- See Also:
-
ON_YES
The event to indicate the Yes button being clicked.- Since:
- 5.0.8
- See Also:
-
ON_NO
The event to indicate the No button being clicked.- Since:
- 5.0.8
- See Also:
-
ON_RETRY
The event to indicate the RETRY button being clicked.- Since:
- 5.0.8
- See Also:
-
ON_ABORT
The event to indicate the Abort button being clicked.- Since:
- 5.0.8
- See Also:
-
ON_IGNORE
The event to indicate the Ignore button being clicked.- Since:
- 5.0.8
- See Also:
-
ON_OK
The event to indicate the OK button being clicked.- Since:
- 5.0.8
- See Also:
-
ON_CANCEL
The event to indicate the Cancel button being clicked.- Since:
- 5.0.8
- See Also:
-
-
Constructor Details
-
Messagebox
public Messagebox()
-
-
Method Details
-
show
public static Messagebox.Button show(String message, String title, Messagebox.Button[] buttons, String[] btnLabels, String icon, Messagebox.Button focus, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener, Map<String, String> params) Shows a message box and returns what button is pressed.- Parameters:
title- the title. If null,WebApp.getAppName()is used.buttons- an array of buttons to show. The buttons will be displayed in the same order in the array.btnLabels- the label used for each button specified in the buttons argument. If null, the default label will be used.icon- one of predefined images:QUESTION,EXCLAMATION,ERROR,NONE, or any style class name(s) to show an image.focus- one of button to have to focus. If null, the first button will gain the focus.listener- the event listener which is invoked when a button is clicked. Ignored if null. It is useful if the event processing thread is disabled (Configuration.enableEventThread(boolean)). If the event processing thread is disabled (system default), this method always returnMessagebox.Button.OK. To know which button is pressed, you have to pass an event listener. Then, when the user clicks a button, the event listener is invoked with an instance ofMessagebox.ClickEvent. You can identify which button is clicked by examiningMessagebox.ClickEvent.getButton()orEvent.getName(). If the close button is clicked, the onClose event is sent andMessagebox.ClickEvent.getButton()return null;params- the parameters passed to the template. Ignored if null. Notice it will override the default parameters if there is any conflict. You could pass anything as long as the template (setTemplate(java.lang.String)) recognized. For the default template, typical parameters are
width: the width of the dialog.
icon: the URI of the iconsclass: the CSS class name of the top level Window (since 7.0.1)- Returns:
- the button being pressed.
Note: if the event processing thread is disabled (system default), it always
returns
Messagebox.Button.OK. - Since:
- 6.0.0
-
show
public static Messagebox.Button show(String message, String title, Messagebox.Button[] buttons, String[] btnLabels, String icon, Messagebox.Button focus, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener) Shows a message box and returns what button is pressed.- Parameters:
title- the title. If null,WebApp.getAppName()is used.buttons- an array of buttons to show. The buttons will be displayed in the same order in the array.btnLabels- the label used for each button specified in the buttons argument. If null, the default label will be used.icon- one of predefined images:QUESTION,EXCLAMATION,ERROR,NONE, or any style class name(s) to show an image.focus- one of button to have to focus. If null, the first button will gain the focus.listener- the event listener which is invoked when a button is clicked. Ignored if null. It is useful if the event processing thread is disabled (Configuration.enableEventThread(boolean)). If the event processing thread is disabled (system default), this method always returnMessagebox.Button.OK. To know which button is pressed, you have to pass an event listener. Then, when the user clicks a button, the event listener is invoked with an instance ofMessagebox.ClickEvent. You can identify which button is clicked by examiningMessagebox.ClickEvent.getButton()orEvent.getName(). If the close button is clicked, the onClose event is sent andMessagebox.ClickEvent.getButton()return null;- Returns:
- the button being pressed.
Note: if the event processing thread is disabled (system default), it always
returns
Messagebox.Button.OK. - Since:
- 6.0.0
-
show
public static Messagebox.Button show(String message, String title, Messagebox.Button[] buttons, String icon, Messagebox.Button focus, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener) Shows a message box and returns what button is pressed.- Parameters:
title- the title. If null,WebApp.getAppName()is used.buttons- an array of buttons to show. The buttons will be displayed in the same order in the array.icon- one of predefined images:QUESTION,EXCLAMATION,ERROR,NONE, or any style class name(s) to show an image.focus- one of button to have to focus. If null, the first button will gain the focus.listener- the event listener which is invoked when a button is clicked. Ignored if null. It is useful if the event processing thread is disabled (Configuration.enableEventThread(boolean)). If the event processing thread is disabled (system default), this method always returnMessagebox.Button.OK. To know which button is pressed, you have to pass an event listener. Then, when the user clicks a button, the event listener is invoked with an instance ofMessagebox.ClickEvent. You can identify which button is clicked by examiningMessagebox.ClickEvent.getButton()orEvent.getName(). If the close button is clicked, the onClose event is sent andMessagebox.ClickEvent.getButton()return null;- Returns:
- the button being pressed.
Note: if the event processing thread is disabled (system default), it always
returns
Messagebox.Button.OK. - Since:
- 6.0.0
-
show
public static Messagebox.Button show(String message, String title, Messagebox.Button[] buttons, String icon, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener) Shows a message box and returns what button is pressed. A shortcut to show(message, title, buttons, icon, null, listener).- Since:
- 6.0.0
-
show
public static Messagebox.Button show(String message, Messagebox.Button[] buttons, org.zkoss.zk.ui.event.EventListener<Messagebox.ClickEvent> listener) Shows a message box and returns what button is pressed. A shortcut to show(message, null, buttons, INFORMATION, null, listener).- Since:
- 6.0.0
-
show
Shows a message box and returns what button is pressed.- Parameters:
title- the title. If null,WebApp.getAppName()is used.buttons- a combination ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE. If zero,OKis assumedicon- one of predefined images:QUESTION,EXCLAMATION,ERROR,NONE, or any style class name(s) to show an image.- Returns:
- the button being pressed (one of
OK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE). Note: if the event processing thread is disabled, it always returnsOK.
-
show
public static int show(String message, String title, int buttons, String icon, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box and returns what button is pressed.- Parameters:
title- the title. If null,WebApp.getAppName()is used.buttons- a combination ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE. If zero,OKis assumedicon- one of predefined images:QUESTION,EXCLAMATION,ERROR,NONE, or any style class name(s) to show an image.listener- the event listener which is invoked when a button is clicked. Ignored if null. It is useful if the event processing thread is disabled (Configuration.enableEventThread(boolean)). If the event processing thread is disabled, this method always returnOK. To know which button is pressed, you have to pass an event listener. Then, when the user clicks a button, the event listener is invoked. You can identify which button is clicked by examining the event name (Event.getName()) as shown in the following table. Alternatively, you can examine the value ofEvent.getData(), which must be an integer representing the button, such asOK,YESand so on.Button Name Event Name OK onOK ( ON_OK)Cancel onCancel ( ON_CANCEL)Yes onYes ( ON_YES)No onNo ( ON_NO)Retry onRetry ( ON_RETRY)Abort onAbort ( ON_ABORT)Ignore onIgnore ( ON_IGNORE)- Returns:
- the button being pressed (one of
OK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE). Note: if the event processing thread is disabled, it always returnsOK. - Since:
- 3.0.4
-
show
Shows a message box and returns what button is pressed.- Parameters:
title- the title. If null,WebApp.getAppName()is used.buttons- a combination ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE. If zero,OKis assumedicon- one of predefined images:QUESTION,EXCLAMATION,ERROR,NONE, or any style class name(s) to show an image.focus- one of button to have to focus. If 0, the first button will gain the focus. One ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE.- Returns:
- the button being pressed (one of
OK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE). Note: if the event processing thread is disabled, it always returnsOK. - Since:
- 3.0.0
-
show
public static int show(String message, String title, int buttons, String icon, int focus, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box and returns what button is pressed.- Parameters:
title- the title. If null,WebApp.getAppName()is used.buttons- a combination ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE. If zero,OKis assumedicon- one of predefined images:QUESTION,EXCLAMATION,ERROR,NONE, or any style class name(s) to show an image.focus- one of button to have to focus. If 0, the first button will gain the focus. One ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE.listener- the event listener which is invoked when a button is clicked. Ignored if null. It is useful if the event processing thread is disabled (Configuration.enableEventThread(boolean)). If the event processing thread is disabled, this method always returnOK. To know which button is pressed, you have to pass an event listener. Then, when the user clicks a button, the event listener is invoked. You can identify which button is clicked by examining the event name (Event.getName()) as shown in the following table. Alternatively, you can examine the value ofEvent.getData(), which must be an integer representing the button, such asOK,YESand so on.Button Event Name OK onOK ( ON_OK)Cancel onCancel ( ON_CANCEL)Yes onYes ( ON_YES)No onNo ( ON_NO)Retry onRetry ( ON_RETRY)Abort onAbort ( ON_ABORT)Ignore onIgnore ( ON_IGNORE)- Returns:
- the button being pressed (one of
OK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE). Note: if the event processing thread is disabled, it always returnsOK. - Since:
- 3.0.4
-
show
Shows a message box and returns what button is pressed. A shortcut to show(message, null, OK, INFORMATION). -
show
Shows a message box by specifying a message code, and returns what button is pressed. -
show
public static int show(int messageCode, Object[] args, int titleCode, int buttons, String icon, int focus) Shows a message box by specifying a message code, and returns what button is pressed.- Parameters:
titleCode- the message code for the title. If non-positive, the default title is used.focus- one of button to have to focus. If 0, the first button will gain the focus. One ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE.- Returns:
- the button being pressed (one of
OK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE). Note: if the event processing thread is disabled, it always returnsOK. - Since:
- 3.0.0
-
show
public static int show(int messageCode, Object[] args, int titleCode, int buttons, String icon, int focus, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box by specifying a message code, and returns what button is pressed.- Parameters:
titleCode- the message code for the title. If non-positive, the default title is used.focus- one of button to have to focus. If 0, the first button will gain the focus. One ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE.listener- the event listener which is invoked when a button is clicked. Ignored if null. It is useful if the event processing thread is disabled (Configuration.enableEventThread(boolean)). If the event processing thread is disabled, this method always returnOK. To know which button is pressed, you have to pass an event listener. Then, when the user clicks a button, the event listener is invoked. You can identify which button is clicked by examining the event name (Event.getName()) as shown in the following table. Alternatively, you can examine the value ofEvent.getData(), which must be an integer representing the button, such asOK,YESand so on.Button Event Name OK onOK ( ON_OK)Cancel onCancel ( ON_CANCEL)Yes onYes ( ON_YES)No onNo ( ON_NO)Retry onRetry ( ON_RETRY)Abort onAbort ( ON_ABORT)Ignore onIgnore ( ON_IGNORE)- Returns:
- the button being pressed (one of
OK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE). Note: if the event processing thread is disabled, it always returnsOK. - Since:
- 3.0.4
-
show
Shows a message box by specifying a message code, and returns what button is pressed. -
show
public static int show(int messageCode, Object arg, int titleCode, int buttons, String icon, int focus) Shows a message box by specifying a message code, and returns what button is pressed.- Parameters:
titleCode- the message code for the title. If non-positive, the default title is used.focus- one of button to have to focus. If 0, the first button will gain the focus. One ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE.- Returns:
- the button being pressed (one of
OK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE). Note: if the event processing thread is disabled, it always returnsOK. - Since:
- 3.0.0
-
show
public static int show(int messageCode, Object arg, int titleCode, int buttons, String icon, int focus, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box by specifying a message code, and returns what button is pressed.- Parameters:
titleCode- the message code for the title. If non-positive, the default title is used.focus- one of button to have to focus. If 0, the first button will gain the focus. One ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE.listener- the event listener which is invoked when a button is clicked. Ignored if null. It is useful if the event processing thread is disabled (Configuration.enableEventThread(boolean)). If the event processing thread is disabled, this method always returnOK. To know which button is pressed, you have to pass an event listener. Then, when the user clicks a button, the event listener is invoked. You can identify which button is clicked by examining the event name (Event.getName()) as shown in the following table. Alternatively, you can examine the value ofEvent.getData(), which must be an integer representing the button, such asOK,YESand so on.Button Event Name OK onOK ( ON_OK)Cancel onCancel ( ON_CANCEL)Yes onYes ( ON_YES)No onNo ( ON_NO)Retry onRetry ( ON_RETRY)Abort onAbort ( ON_ABORT)Ignore onIgnore ( ON_IGNORE)- Returns:
- the button being pressed (one of
OK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE). Note: if the event processing thread is disabled, it always returnsOK. - Since:
- 3.0.4
-
show
Shows a message box by specifying a message code, and returns what button is pressed.- Parameters:
titleCode- the message code for the title. If non-positive, the default title is used.
-
show
Shows a message box by specifying a message code, and returns what button is pressed. -
show
public static int show(int messageCode, int titleCode, int buttons, String icon, int focus, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event> listener) Shows a message box by specifying a message code, and returns what button is pressed.- Parameters:
titleCode- the message code for the title. If non-positive, the default title is used.focus- one of button to have to focus. If 0, the first button will gain the focus. One ofOK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE.listener- the event listener which is invoked when a button is clicked. Ignored if null. It is useful if the event processing thread is disabled (Configuration.enableEventThread(boolean)). If the event processing thread is disabled, this method always returnOK. To know which button is pressed, you have to pass an event listener. Then, when the user clicks a button, the event listener is invoked. You can identify which button is clicked by examining the event name (Event.getName()) as shown in the following table. Alternatively, you can examine the value ofEvent.getData(), which must be an integer representing the button, such asOK,YESand so on.Button Event Name OK onOK ( ON_OK)Cancel onCancel ( ON_CANCEL)Yes onYes ( ON_YES)No onNo ( ON_NO)Retry onRetry ( ON_RETRY)Abort onAbort ( ON_ABORT)Ignore onIgnore ( ON_IGNORE)The close button on the right-top corner (x)
since 5.0.2onClose - Returns:
- the button being pressed (one of
OK,CANCEL,YES,NO,ABORT,RETRY, andIGNORE). Note: if the event processing thread is disabled, it always returnsOK. - Since:
- 3.0.4
-
setTemplate
Sets the template used to create the message dialog.The template must follow the default template: ~./zul/html/messagebox.zul
In other words, just adjust the label and layout and don't change the component's ID.
-
getTemplate
Returns the template used to create the message dialog.
-