Class ConfirmDialog
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.confirmdialog.ConfirmDialog
-
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasOrderedComponents,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,Serializable
@Tag("vaadin-confirm-dialog") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="23.6.1") @NpmPackage(value="@vaadin/confirm-dialog",version="23.6.1") @NpmPackage(value="@vaadin/vaadin-confirm-dialog",version="23.6.1") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/confirm-dialog/src/vaadin-confirm-dialog.js") @JsModule("./confirmDialogConnector.js") public class ConfirmDialog extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasOrderedComponentsConfirm Dialog is a modal Dialog used to confirm user actions.Confirm Dialog consists of:
- Title
- Message
- Footer
- “Cancel” button
- “Reject” button
- “Confirm” button
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConfirmDialog.CancelEvent`cancel` is sent when the user clicks Cancel button or presses Escape key.static classConfirmDialog.ConfirmEvent`confirm` is sent when the user clicks Confirm buttonstatic classConfirmDialog.RejectEvent`reject` is sent when the user clicks Reject button
-
Constructor Summary
Constructors Constructor Description ConfirmDialog()Creates an empty dialog with a Confirm buttonConfirmDialog(String header, String text, String confirmText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener)Creates a dialog with a Confirm button with its click listener and a given textsConfirmDialog(String header, String text, String confirmText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener, String cancelText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)Creates a two button dialog with Confirm and Cancel buttonsConfirmDialog(String header, String text, String confirmText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener, String rejectText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener, String cancelText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)Creates a three button dialog with Confirm, Reject and Cancel buttons
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.vaadin.flow.shared.RegistrationaddCancelListener(com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> listener)Adds `cancel` event listenercom.vaadin.flow.shared.RegistrationaddConfirmListener(com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> listener)Adds `confirm` event listenercom.vaadin.flow.shared.RegistrationaddRejectListener(com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.RejectEvent> listener)Adds `reject` event listenervoidclose()Closes the dialog.com.vaadin.flow.dom.StylegetStyle()booleanisCloseOnEsc()Gets whether this dialog can be closed by hitting the esc-key or not.booleanisOpened()protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent)voidopen()Opens the dialog.voidsetCancelable(boolean cancelable)Whether to show or hide Cancel button.voidsetCancelButton(com.vaadin.flow.component.Component component)Sets custom cancel buttonvoidsetCancelButton(com.vaadin.flow.dom.Element element)Sets custom cancel buttonvoidsetCancelButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)Sets Cancel button text and `cancel` event listener.voidsetCancelButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener, String theme)Sets Cancel button text, `cancel` event listener and Cancel button theme.voidsetCancelButtonTheme(String cancelTheme)Sets Cancel button themevoidsetCancelText(String cancelText)Sets Cancel button textvoidsetCloseOnEsc(boolean closeOnEsc)Sets whether this dialog can be closed by hitting the esc-key or not.voidsetConfirmButton(com.vaadin.flow.component.Component component)Sets custom confirm buttonvoidsetConfirmButton(com.vaadin.flow.dom.Element element)Sets custom confirm buttonvoidsetConfirmButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener)Sets Confirm button text and `confirm` event listenervoidsetConfirmButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener, String theme)Sets Confirm button text, `confirm` event listener and Confirm button themevoidsetConfirmButtonTheme(String confirmTheme)Sets Confirm button themevoidsetConfirmText(String confirmText)Sets Confirm button textvoidsetHeader(com.vaadin.flow.component.Component component)Sets confirmation dialog custom header elementvoidsetHeader(com.vaadin.flow.dom.Element element)Sets confirmation dialog custom header elementvoidsetHeader(String header)Sets confirmation dialog header textvoidsetHeight(String height)Sets the height of the component content area.voidsetOpened(boolean opened)Opens or closes the dialog.voidsetRejectable(boolean rejectable)Whether to show or hide Reject button.voidsetRejectButton(com.vaadin.flow.component.Component component)Sets custom Reject buttonvoidsetRejectButton(com.vaadin.flow.dom.Element element)Sets custom Reject buttonvoidsetRejectButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener)Sets Reject button text and `reject` event listener.voidsetRejectButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener, String theme)Sets Reject button text, `reject` event listener, Reject button theme.voidsetRejectButtonTheme(String rejectTheme)Sets Reject button themevoidsetRejectText(String rejectText)Sets Reject button textvoidsetText(com.vaadin.flow.component.Component component)Sets custom confirmation message elementvoidsetText(com.vaadin.flow.dom.Element element)Sets custom confirmation message elementvoidsetText(String message)Sets confirmation message textvoidsetWidth(String width)Sets the width of the component content area.voidupdateHeight()-
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAll
-
Methods inherited from interface com.vaadin.flow.component.HasOrderedComponents
getChildren, getComponentAt, getComponentCount, indexOf, replace
-
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFull
-
-
-
-
Constructor Detail
-
ConfirmDialog
public ConfirmDialog()
Creates an empty dialog with a Confirm button
-
ConfirmDialog
public ConfirmDialog(String header, String text, String confirmText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener)
Creates a dialog with a Confirm button with its click listener and a given texts- Parameters:
header- the header texttext- the confirmation message textconfirmText- the text inside Confirm buttonconfirmListener- the event listener for `confirm` event- See Also:
setHeader(String),setText(String),setConfirmButton(String, ComponentEventListener)
-
ConfirmDialog
public ConfirmDialog(String header, String text, String confirmText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener, String cancelText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)
Creates a two button dialog with Confirm and Cancel buttons- Parameters:
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` event- See Also:
setHeader(String),setText(String),setConfirmButton(String, ComponentEventListener),setCancelButton(String, ComponentEventListener)
-
ConfirmDialog
public ConfirmDialog(String header, String text, String confirmText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener, String rejectText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener, String cancelText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)
Creates a three button dialog with Confirm, Reject and Cancel buttons- Parameters:
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` event- See Also:
setHeader(String),setText(String),setConfirmButton(String, ComponentEventListener),setCancelButton(String, ComponentEventListener),setRejectButton(String, ComponentEventListener)
-
-
Method Detail
-
setWidth
public void setWidth(String width)
Sets the width of the component content area.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
widthvalue is null then width is removed.- Specified by:
setWidthin interfacecom.vaadin.flow.component.HasSize- Parameters:
width- the width to set, may benull
-
setHeight
public void setHeight(String height)
Sets the height of the component content area.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
heightvalue is null then height is removed.- Specified by:
setHeightin interfacecom.vaadin.flow.component.HasSize- Parameters:
height- the height to set, may benull
-
updateHeight
public void updateHeight()
-
getStyle
public com.vaadin.flow.dom.Style getStyle()
- Specified by:
getStylein interfacecom.vaadin.flow.component.HasStyle- Throws:
UnsupportedOperationException- ConfirmDialog does not support adding styles to overlay
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
- Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
setCancelable
public void setCancelable(boolean cancelable)
Whether to show or hide Cancel button.
-
setRejectable
public void setRejectable(boolean rejectable)
Whether to show or hide Reject button.
-
setRejectButton
public void setRejectButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener)
Sets Reject button text and `reject` event listener. Makes Reject button visible- Parameters:
buttonText- the text inside Reject buttonrejectListener- the event listener for `reject` event
-
setRejectButton
public void setRejectButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.RejectEvent> rejectListener, String theme)
Sets Reject button text, `reject` event listener, Reject button theme. Makes Reject button visible- Parameters:
buttonText- the text inside Reject buttonrejectListener- the event listener for `reject` eventtheme- the theme applied for a Reject button
-
setRejectButton
public void setRejectButton(com.vaadin.flow.component.Component component)
Sets custom Reject button- Parameters:
component- the component to display instead of default Reject button
-
setRejectButton
public void setRejectButton(com.vaadin.flow.dom.Element element)
Sets custom Reject button- Parameters:
element- the element to display instead of default Reject button
-
setCancelButton
public void setCancelButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener)
Sets Cancel button text and `cancel` event listener. Makes Cancel button visible- Parameters:
buttonText- the text inside Cancel buttoncancelListener- the event listener for `cancel` event
-
setCancelButton
public void setCancelButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> cancelListener, String theme)
Sets Cancel button text, `cancel` event listener and Cancel button theme. Makes Cancel button visible- Parameters:
buttonText- the text inside Cancel buttoncancelListener- the event listener for `cancel` eventtheme- the theme applied for a Cancel button
-
setCancelButton
public void setCancelButton(com.vaadin.flow.component.Component component)
Sets custom cancel button- Parameters:
component- the component to display instead of default Cancel button
-
setCancelButton
public void setCancelButton(com.vaadin.flow.dom.Element element)
Sets custom cancel button- Parameters:
element- the element to display instead of default Cancel button
-
setConfirmButton
public void setConfirmButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener)
Sets Confirm button text and `confirm` event listener- Parameters:
buttonText- the text inside Confirm buttonconfirmListener- the event listener for `confirm` event
-
setConfirmButton
public void setConfirmButton(String buttonText, com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> confirmListener, String theme)
Sets Confirm button text, `confirm` event listener and Confirm button theme- Parameters:
buttonText- the text inside Confirm buttonconfirmListener- the event listener for `confirm` eventtheme- the theme applied for a Confirm button
-
setConfirmButton
public void setConfirmButton(com.vaadin.flow.component.Component component)
Sets custom confirm button- Parameters:
component- the element to display instead of default Confirm button
-
setConfirmButton
public void setConfirmButton(com.vaadin.flow.dom.Element element)
Sets custom confirm button- Parameters:
element- the element to display instead of default Confirm button
-
setText
public void setText(String message)
Sets confirmation message text
-
setText
public void setText(com.vaadin.flow.component.Component component)
Sets custom confirmation message element- Parameters:
component- the component to display instead of default confirmation text node
-
setText
public void setText(com.vaadin.flow.dom.Element element)
Sets custom confirmation message element- Parameters:
element- the element to display instead of default confirmation text node
-
setConfirmText
public void setConfirmText(String confirmText)
Sets Confirm button text
-
setConfirmButtonTheme
public void setConfirmButtonTheme(String confirmTheme)
Sets Confirm button theme
-
addConfirmListener
public com.vaadin.flow.shared.Registration addConfirmListener(com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.ConfirmEvent> listener)
Adds `confirm` event listener
-
setCancelText
public void setCancelText(String cancelText)
Sets Cancel button text
-
setCancelButtonTheme
public void setCancelButtonTheme(String cancelTheme)
Sets Cancel button theme
-
addCancelListener
public com.vaadin.flow.shared.Registration addCancelListener(com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.CancelEvent> listener)
Adds `cancel` event listener
-
setRejectText
public void setRejectText(String rejectText)
Sets Reject button text
-
setRejectButtonTheme
public void setRejectButtonTheme(String rejectTheme)
Sets Reject button theme
-
addRejectListener
public com.vaadin.flow.shared.Registration addRejectListener(com.vaadin.flow.component.ComponentEventListener<ConfirmDialog.RejectEvent> listener)
Adds `reject` event listener
-
setHeader
public void setHeader(String header)
Sets confirmation dialog header text
-
setHeader
public void setHeader(com.vaadin.flow.component.Component component)
Sets confirmation dialog custom header element- Parameters:
component- the component to display instead of default header text
-
setHeader
public void setHeader(com.vaadin.flow.dom.Element element)
Sets confirmation dialog custom header element- Parameters:
element- the element to display instead of default header text
-
open
public void open()
Opens the dialog.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.
-
close
public void close()
Closes the dialog.Note: This method also removes the dialog component from the DOM after closing it, unless you have added the component manually.
-
isOpened
@Synchronize(property="opened", value="opened-changed") public boolean isOpened()
-
setOpened
public void setOpened(boolean opened)
Opens or closes the dialog.Note: Confirm-dialog will be attached or detached from the DOM automatically, if it was not added manually.
- Parameters:
opened-trueto open the confirm-dialog,falseto close it
-
isCloseOnEsc
public boolean isCloseOnEsc()
Gets whether this dialog can be closed by hitting the esc-key or not.By default, the dialog is closable with esc.
- Returns:
trueif this dialog can be closed with the esc-key,falseotherwise
-
setCloseOnEsc
public void setCloseOnEsc(boolean closeOnEsc)
Sets whether this dialog can be closed by hitting the esc-key or not.By default, the dialog is closable with esc.
- Parameters:
closeOnEsc-trueto enable closing this dialog with the esc-key,falseto disable it
-
-