@Tag(value="vaadin-confirm-dialog") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="22.0.21") @NpmPackage(value="@vaadin/confirm-dialog",version="22.0.21") @NpmPackage(value="@vaadin/vaadin-confirm-dialog",version="22.0.21") @JsModule(value="@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule(value="@vaadin/confirm-dialog/src/vaadin-confirm-dialog.js") public class ConfirmDialog extends Component implements HasSize, HasStyle, HasOrderedComponents
<vaadin-confirm-dialog>
element.Modifier and Type | Class and Description |
---|---|
static class |
ConfirmDialog.CancelEvent
`cancel` is sent when the user clicks Cancel button or presses Escape
key.
|
static class |
ConfirmDialog.ConfirmEvent
`confirm` is sent when the user clicks Confirm button
|
static class |
ConfirmDialog.RejectEvent
`reject` is sent when the user clicks Reject button
|
Constructor and Description |
---|
ConfirmDialog()
Creates an empty dialog with a Confirm button
|
ConfirmDialog(String header,
String text,
String confirmText,
ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener)
Creates a dialog with a Confirm button with its click listener and a
given texts
|
ConfirmDialog(String header,
String text,
String confirmText,
ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener,
String cancelText,
ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)
Creates a two button dialog with Confirm and Cancel buttons
|
ConfirmDialog(String header,
String text,
String confirmText,
ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener,
String rejectText,
ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener,
String cancelText,
ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)
Creates a three button dialog with Confirm, Reject and Cancel buttons
|
Modifier and Type | Method and Description |
---|---|
Registration |
addCancelListener(ComponentEventListener<ConfirmDialog.CancelEvent> listener)
Adds `cancel` event listener
|
Registration |
addConfirmListener(ComponentEventListener<ConfirmDialog.ConfirmEvent> listener)
Adds `confirm` event listener
|
Registration |
addRejectListener(ComponentEventListener<ConfirmDialog.RejectEvent> listener)
Adds `reject` event listener
|
void |
close()
Closes the dialog.
|
boolean |
isOpened() |
void |
open()
Opens the dialog.
|
void |
setCancelable(boolean cancelable)
Whether to show or hide Cancel button.
|
void |
setCancelButton(Component component)
Sets custom cancel button
|
void |
setCancelButton(Element element)
Sets custom cancel button
|
void |
setCancelButton(String buttonText,
ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)
Sets Cancel button text and `cancel` event listener.
|
void |
setCancelButton(String buttonText,
ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener,
String theme)
Sets Cancel button text, `cancel` event listener and Cancel button theme.
|
void |
setCancelButtonTheme(String cancelTheme)
Sets Cancel button theme
|
void |
setCancelText(String cancelText)
Sets Cancel button text
|
void |
setConfirmButton(Component component)
Sets custom confirm button
|
void |
setConfirmButton(Element element)
Sets custom confirm button
|
void |
setConfirmButton(String buttonText,
ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener)
Sets Confirm button text and `confirm` event listener
|
void |
setConfirmButton(String buttonText,
ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener,
String theme)
Sets Confirm button text, `confirm` event listener and Confirm button
theme
|
void |
setConfirmButtonTheme(String confirmTheme)
Sets Confirm button theme
|
void |
setConfirmText(String confirmText)
Sets Confirm button text
|
void |
setHeader(Component component)
Sets confirmation dialog custom header element
|
void |
setHeader(Element element)
Sets confirmation dialog custom header element
|
void |
setHeader(String header)
Sets confirmation dialog header text
|
void |
setHeight(String height)
Sets the height of the component content area.
|
void |
setOpened(boolean opened)
Opens or closes the dialog.
|
void |
setRejectable(boolean rejectable)
Whether to show or hide Reject button.
|
void |
setRejectButton(Component component)
Sets custom Reject button
|
void |
setRejectButton(Element element)
Sets custom Reject button
|
void |
setRejectButton(String buttonText,
ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener)
Sets Reject button text and `reject` event listener.
|
void |
setRejectButton(String buttonText,
ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener,
String theme)
Sets Reject button text, `reject` event listener, Reject button theme.
|
void |
setRejectButtonTheme(String rejectTheme)
Sets Reject button theme
|
void |
setRejectText(String rejectText)
Sets Reject button text
|
void |
setText(Component component)
Sets custom confirmation message element
|
void |
setText(Element element)
Sets custom confirmation message element
|
void |
setText(String message)
Sets confirmation message text
|
void |
setWidth(String width)
Sets the width of the component content area.
|
void |
updateHeight() |
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFull
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
getChildren, getComponentAt, getComponentCount, indexOf, replace
add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAll
isEnabled, setEnabled
getElement
addAttachListener
addDetachListener
public ConfirmDialog()
public ConfirmDialog(String header, String text, String confirmText, ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener)
header
- the header texttext
- the confirmation message textconfirmText
- the text inside Confirm buttonconfirmListener
- the event listener for `confirm` eventsetHeader(String)
,
setText(String)
,
setConfirmButton(String, ComponentEventListener)
public ConfirmDialog(String header, String text, String confirmText, ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener, String cancelText, ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)
header
- the header texttext
- the confirmation message textconfirmText
- the text inside Confirm buttonconfirmListener
- the event listener for `confirm` eventcancelText
- the text inside Cancel buttoncancelListener
- the event listener for `cancel` eventsetHeader(String)
,
setText(String)
,
setConfirmButton(String, ComponentEventListener)
,
setCancelButton(String, ComponentEventListener)
public ConfirmDialog(String header, String text, String confirmText, ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener, String rejectText, ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener, String cancelText, ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)
header
- the header texttext
- the confirmation message textconfirmText
- the text inside Confirm buttonconfirmListener
- the event listener for `confirm` eventrejectText
- the text inside Reject buttonrejectListener
- the event listener for `reject` eventcancelText
- the text inside Cancel buttoncancelListener
- the event listener for `cancel` eventsetHeader(String)
,
setText(String)
,
setConfirmButton(String, ComponentEventListener)
,
setCancelButton(String, ComponentEventListener)
,
setRejectButton(String, ComponentEventListener)
public void setWidth(String width)
The width should be in a format understood by the browser, e.g. "100px" or "2.5em" (Using relative unit, such as percentage, will lead to unexpected results).
If the provided width
value is null then width is
removed.
public void setHeight(String height)
The height should be in a format understood by the browser, e.g. "100px" or "2.5em" (Using relative unit, such as percentage, will lead to unexpected results).
If the provided height
value is null then height is
removed.
public void updateHeight()
public void setCancelable(boolean cancelable)
public void setRejectable(boolean rejectable)
public void setRejectButton(String buttonText, ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener)
buttonText
- the text inside Reject buttonrejectListener
- the event listener for `reject` eventpublic void setRejectButton(String buttonText, ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener, String theme)
buttonText
- the text inside Reject buttonrejectListener
- the event listener for `reject` eventtheme
- the theme applied for a Reject buttonpublic void setRejectButton(Component component)
component
- the component to display instead of default Reject buttonpublic void setRejectButton(Element element)
element
- the element to display instead of default Reject buttonpublic void setCancelButton(String buttonText, ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)
buttonText
- the text inside Cancel buttoncancelListener
- the event listener for `cancel` eventpublic void setCancelButton(String buttonText, ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener, String theme)
buttonText
- the text inside Cancel buttoncancelListener
- the event listener for `cancel` eventtheme
- the theme applied for a Cancel buttonpublic void setCancelButton(Component component)
component
- the component to display instead of default Cancel buttonpublic void setCancelButton(Element element)
element
- the element to display instead of default Cancel buttonpublic void setConfirmButton(String buttonText, ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener)
buttonText
- the text inside Confirm buttonconfirmListener
- the event listener for `confirm` eventpublic void setConfirmButton(String buttonText, ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener, String theme)
buttonText
- the text inside Confirm buttonconfirmListener
- the event listener for `confirm` eventtheme
- the theme applied for a Confirm buttonpublic void setConfirmButton(Component component)
component
- the element to display instead of default Confirm buttonpublic void setConfirmButton(Element element)
element
- the element to display instead of default Confirm buttonpublic void setText(String message)
public void setText(Component component)
component
- the component to display instead of default confirmation text
nodepublic void setText(Element element)
element
- the element to display instead of default confirmation text
nodepublic void setConfirmText(String confirmText)
public void setConfirmButtonTheme(String confirmTheme)
public Registration addConfirmListener(ComponentEventListener<ConfirmDialog.ConfirmEvent> listener)
public void setCancelText(String cancelText)
public void setCancelButtonTheme(String cancelTheme)
public Registration addCancelListener(ComponentEventListener<ConfirmDialog.CancelEvent> listener)
public void setRejectText(String rejectText)
public void setRejectButtonTheme(String rejectTheme)
public Registration addRejectListener(ComponentEventListener<ConfirmDialog.RejectEvent> listener)
public void setHeader(String header)
public void setHeader(Component component)
component
- the component to display instead of default header textpublic void setHeader(Element element)
element
- the element to display instead of default header textpublic void open()
Note: You don't need to add the dialog component before opening it, cause
opening a dialog will automatically add it to the <body>
if it's
not yet attached anywhere.
public void close()
Note: This method also removes the dialog component from the DOM after closing it, unless you have added the component manually.
@Synchronize(property="opened", value="opened-changed") public boolean isOpened()
public void setOpened(boolean opened)
Note: Confirm-dialog will be attached or detached from the DOM automatically, if it was not added manually.
opened
- true
to open the confirm-dialog, false
to
close itCopyright © 2022. All rights reserved.