public class Messagebox
extends java.lang.Object
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.
Modifier and Type | Class and Description |
---|---|
static class |
Messagebox.Button
The button types.
|
static class |
Messagebox.ClickEvent
The event that will be received by the listener when the user clicks a button.
|
Modifier and Type | Field and Description |
---|---|
static int |
ABORT
A Abort button.
|
static int |
CANCEL
A Cancel button.
|
static java.lang.String |
ERROR
A symbol consisting of a white X in a circle with a red background.
|
static java.lang.String |
EXCLAMATION
A symbol consisting of an exclamation point in a triangle with
a yellow background
Since 3.5.0, they are actually style class names to display the icon.
|
static int |
IGNORE
A IGNORE button.
|
static java.lang.String |
INFORMATION
A symbol of a lower case letter i in a circle.
|
static int |
NO
A No button.
|
static java.lang.String |
NONE
Contains no symbols.
|
static int |
OK
A OK button.
|
static java.lang.String |
ON_ABORT
The event to indicate the Abort button being clicked.
|
static java.lang.String |
ON_CANCEL
The event to indicate the Cancel button being clicked.
|
static java.lang.String |
ON_IGNORE
The event to indicate the Ignore button being clicked.
|
static java.lang.String |
ON_NO
The event to indicate the No button being clicked.
|
static java.lang.String |
ON_OK
The event to indicate the OK button being clicked.
|
static java.lang.String |
ON_RETRY
The event to indicate the RETRY button being clicked.
|
static java.lang.String |
ON_YES
The event to indicate the Yes button being clicked.
|
static java.lang.String |
QUESTION
A symbol consisting of a question mark in a circle.
|
static int |
RETRY
A Retry button.
|
static int |
YES
A Yes button.
|
Constructor and Description |
---|
Messagebox() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getTemplate()
Returns the template used to create the message dialog.
|
static void |
setTemplate(java.lang.String uri)
Sets the template used to create the message dialog.
|
static int |
show(int messageCode,
int titleCode,
int buttons,
java.lang.String icon)
Shows a message box by specifying a message code, and returns what
button is pressed.
|
static int |
show(int messageCode,
int titleCode,
int buttons,
java.lang.String icon,
int focus)
Shows a message box by specifying a message code, and returns what
button is pressed.
|
static int |
show(int messageCode,
int titleCode,
int buttons,
java.lang.String icon,
int focus,
EventListener<Event> listener)
Shows a message box by specifying a message code, and returns what
button is pressed.
|
static int |
show(int messageCode,
java.lang.Object[] args,
int titleCode,
int buttons,
java.lang.String icon)
Shows a message box by specifying a message code, and returns what
button is pressed.
|
static int |
show(int messageCode,
java.lang.Object[] args,
int titleCode,
int buttons,
java.lang.String icon,
int focus)
Shows a message box by specifying a message code, and returns what
button is pressed.
|
static int |
show(int messageCode,
java.lang.Object[] args,
int titleCode,
int buttons,
java.lang.String icon,
int focus,
EventListener<Event> listener)
Shows a message box by specifying a message code, and returns what
button is pressed.
|
static int |
show(int messageCode,
java.lang.Object arg,
int titleCode,
int buttons,
java.lang.String icon)
Shows a message box by specifying a message code, and returns what
button is pressed.
|
static int |
show(int messageCode,
java.lang.Object arg,
int titleCode,
int buttons,
java.lang.String icon,
int focus)
Shows a message box by specifying a message code, and returns what
button is pressed.
|
static int |
show(int messageCode,
java.lang.Object arg,
int titleCode,
int buttons,
java.lang.String icon,
int focus,
EventListener<Event> listener)
Shows a message box by specifying a message code, and returns what
button is pressed.
|
static int |
show(java.lang.String message)
Shows a message box and returns what button is pressed.
|
static Messagebox.Button |
show(java.lang.String message,
Messagebox.Button[] buttons,
EventListener<Messagebox.ClickEvent> listener)
Shows a message box and returns what button is pressed.
|
static int |
show(java.lang.String message,
java.lang.String title,
int buttons,
java.lang.String icon)
Shows a message box and returns what button is pressed.
|
static int |
show(java.lang.String message,
java.lang.String title,
int buttons,
java.lang.String icon,
EventListener<Event> listener)
Shows a message box and returns what button is pressed.
|
static int |
show(java.lang.String message,
java.lang.String title,
int buttons,
java.lang.String icon,
int focus)
Shows a message box and returns what button is pressed.
|
static int |
show(java.lang.String message,
java.lang.String title,
int buttons,
java.lang.String icon,
int focus,
EventListener<Event> listener)
Shows a message box and returns what button is pressed.
|
static Messagebox.Button |
show(java.lang.String message,
java.lang.String title,
Messagebox.Button[] buttons,
java.lang.String[] btnLabels,
java.lang.String icon,
Messagebox.Button focus,
EventListener<Messagebox.ClickEvent> listener)
Shows a message box and returns what button is pressed.
|
static Messagebox.Button |
show(java.lang.String message,
java.lang.String title,
Messagebox.Button[] buttons,
java.lang.String[] btnLabels,
java.lang.String icon,
Messagebox.Button focus,
EventListener<Messagebox.ClickEvent> listener,
java.util.Map<java.lang.String,java.lang.String> params)
Shows a message box and returns what button is pressed.
|
static Messagebox.Button |
show(java.lang.String message,
java.lang.String title,
Messagebox.Button[] buttons,
java.lang.String icon,
EventListener<Messagebox.ClickEvent> listener)
Shows a message box and returns what button is pressed.
|
static Messagebox.Button |
show(java.lang.String message,
java.lang.String title,
Messagebox.Button[] buttons,
java.lang.String icon,
Messagebox.Button focus,
EventListener<Messagebox.ClickEvent> listener)
Shows a message box and returns what button is pressed.
|
public static final java.lang.String QUESTION
Since 3.5.0, they are actually style class names to display the icon.
public static final java.lang.String EXCLAMATION
Since 3.5.0, they are actually style class names to display the icon.
public static final java.lang.String INFORMATION
Since 3.5.0, they are actually style class names to display the icon.
public static final java.lang.String ERROR
Since 3.5.0, they are actually style class names to display the icon.
public static final java.lang.String NONE
public static final int OK
public static final int CANCEL
public static final int YES
public static final int NO
public static final int ABORT
public static final int RETRY
public static final int IGNORE
public static final java.lang.String ON_YES
public static final java.lang.String ON_NO
public static final java.lang.String ON_RETRY
public static final java.lang.String ON_ABORT
public static final java.lang.String ON_IGNORE
public static final java.lang.String ON_OK
public static final java.lang.String ON_CANCEL
public static Messagebox.Button show(java.lang.String message, java.lang.String title, Messagebox.Button[] buttons, java.lang.String[] btnLabels, java.lang.String icon, Messagebox.Button focus, EventListener<Messagebox.ClickEvent> listener, java.util.Map<java.lang.String,java.lang.String> params)
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
return Messagebox.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 of Messagebox.ClickEvent
.
You can identify which button is clicked
by examining Messagebox.ClickEvent.getButton()
or Event.getName()
.
If the close button is clicked, the onClose event is sent and
Messagebox.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 arewidth
: the width of the dialog.icon
: the URI of the icon
sclass
: the CSS class name of the top level Window (since 7.0.1)Messagebox.Button.OK
.public static Messagebox.Button show(java.lang.String message, java.lang.String title, Messagebox.Button[] buttons, java.lang.String[] btnLabels, java.lang.String icon, Messagebox.Button focus, EventListener<Messagebox.ClickEvent> listener)
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
return Messagebox.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 of Messagebox.ClickEvent
.
You can identify which button is clicked
by examining Messagebox.ClickEvent.getButton()
or Event.getName()
.
If the close button is clicked, the onClose event is sent and
Messagebox.ClickEvent.getButton()
return null;Messagebox.Button.OK
.public static Messagebox.Button show(java.lang.String message, java.lang.String title, Messagebox.Button[] buttons, java.lang.String icon, Messagebox.Button focus, EventListener<Messagebox.ClickEvent> listener)
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
return Messagebox.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 of Messagebox.ClickEvent
.
You can identify which button is clicked
by examining Messagebox.ClickEvent.getButton()
or Event.getName()
.
If the close button is clicked, the onClose event is sent and
Messagebox.ClickEvent.getButton()
return null;Messagebox.Button.OK
.public static Messagebox.Button show(java.lang.String message, java.lang.String title, Messagebox.Button[] buttons, java.lang.String icon, EventListener<Messagebox.ClickEvent> listener)
public static Messagebox.Button show(java.lang.String message, Messagebox.Button[] buttons, EventListener<Messagebox.ClickEvent> listener)
public static int show(java.lang.String message, java.lang.String title, int buttons, java.lang.String icon)
title
- the title. If null, WebApp.getAppName()
is used.buttons
- a combination of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
. If zero, OK
is assumedicon
- one of predefined images: QUESTION
,
EXCLAMATION
, ERROR
, NONE
, or any style class
name(s) to show an image.OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
).
Note: if the event processing thread is disabled, it always
returns OK
.public static int show(java.lang.String message, java.lang.String title, int buttons, java.lang.String icon, EventListener<Event> listener)
title
- the title. If null, WebApp.getAppName()
is used.buttons
- a combination of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
. If zero, OK
is 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
return 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. 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
of Event.getData()
, which must be an
integer representing the button, such as OK
, YES
and 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 ) |
OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
).
Note: if the event processing thread is disabled, it always
returns OK
.public static int show(java.lang.String message, java.lang.String title, int buttons, java.lang.String icon, int focus)
title
- the title. If null, WebApp.getAppName()
is used.buttons
- a combination of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
. If zero, OK
is 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 of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
.OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
).
Note: if the event processing thread is disabled, it always
returns OK
.public static int show(java.lang.String message, java.lang.String title, int buttons, java.lang.String icon, int focus, EventListener<Event> listener)
title
- the title. If null, WebApp.getAppName()
is used.buttons
- a combination of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
. If zero, OK
is 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 of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
.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
return 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. 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
of Event.getData()
, which must be an
integer representing the button, such as OK
, YES
and 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 ) |
OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
).
Note: if the event processing thread is disabled, it always
returns OK
.public static int show(java.lang.String message)
public static int show(int messageCode, java.lang.Object[] args, int titleCode, int buttons, java.lang.String icon)
public static int show(int messageCode, java.lang.Object[] args, int titleCode, int buttons, java.lang.String icon, int focus)
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 of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
.OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
).
Note: if the event processing thread is disabled, it always
returns OK
.public static int show(int messageCode, java.lang.Object[] args, int titleCode, int buttons, java.lang.String icon, int focus, EventListener<Event> listener)
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 of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
.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
return 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. 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
of Event.getData()
, which must be an
integer representing the button, such as OK
, YES
and 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 ) |
OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
).
Note: if the event processing thread is disabled, it always
returns OK
.public static int show(int messageCode, java.lang.Object arg, int titleCode, int buttons, java.lang.String icon)
public static int show(int messageCode, java.lang.Object arg, int titleCode, int buttons, java.lang.String icon, int focus)
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 of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
.OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
).
Note: if the event processing thread is disabled, it always
returns OK
.public static int show(int messageCode, java.lang.Object arg, int titleCode, int buttons, java.lang.String icon, int focus, EventListener<Event> listener)
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 of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
.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
return 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. 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
of Event.getData()
, which must be an
integer representing the button, such as OK
, YES
and 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 ) |
OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
).
Note: if the event processing thread is disabled, it always
returns OK
.public static int show(int messageCode, int titleCode, int buttons, java.lang.String icon)
titleCode
- the message code for the title. If non-positive,
the default title is used.public static int show(int messageCode, int titleCode, int buttons, java.lang.String icon, int focus)
public static int show(int messageCode, int titleCode, int buttons, java.lang.String icon, int focus, EventListener<Event> listener)
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 of OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
.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
return 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. 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
of Event.getData()
, which must be an
integer representing the button, such as OK
, YES
and 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.2 | onClose |
OK
, CANCEL
,
YES
, NO
, ABORT
, RETRY
,
and IGNORE
).
Note: if the event processing thread is disabled, it always
returns OK
.public static void setTemplate(java.lang.String uri)
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.
public static java.lang.String getTemplate()
Copyright © 2005-2021 Potix Corporation. All Rights Reserved.