@JsModule(value="./flow-component-renderer.js") public class Dialog extends GeneratedVaadinDialog<Dialog> implements com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasTheme
<vaadin-dialog> element.| Modifier and Type | Class and Description |
|---|---|
static class |
Dialog.DialogCloseActionEvent
`vaadin-dialog-close-action` is sent when the user clicks outside the
overlay or presses the escape key.
|
static class |
Dialog.DialogResizeEvent
`resize` event is sent when the user finishes resizing the overlay.
|
GeneratedVaadinDialog.OpenedChangeEvent<R extends GeneratedVaadinDialog<R>>| Constructor and Description |
|---|
Dialog()
Creates an empty dialog.
|
Dialog(com.vaadin.flow.component.Component... components)
Creates a dialog with given components inside.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(com.vaadin.flow.component.Component... components)
Adds the given components into this dialog.
|
com.vaadin.flow.shared.Registration |
addAttachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.AttachEvent> listener) |
void |
addComponentAtIndex(int index,
com.vaadin.flow.component.Component component)
Adds the given component into this dialog at the given index.
|
com.vaadin.flow.shared.Registration |
addDetachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.DetachEvent> listener) |
com.vaadin.flow.shared.Registration |
addDialogCloseActionListener(com.vaadin.flow.component.ComponentEventListener<Dialog.DialogCloseActionEvent> listener)
Add a listener that controls whether the dialog should be closed or not.
|
com.vaadin.flow.shared.Registration |
addOpenedChangeListener(com.vaadin.flow.component.ComponentEventListener<GeneratedVaadinDialog.OpenedChangeEvent<Dialog>> listener)
Add a lister for event fired by the
opened-changed events. |
com.vaadin.flow.shared.Registration |
addResizeListener(com.vaadin.flow.component.ComponentEventListener<Dialog.DialogResizeEvent> listener)
Adds a listener that is called after user finishes resizing the overlay.
|
void |
addThemeVariants(DialogVariant... variants)
Adds theme variants to the component.
|
void |
close()
Closes the dialog.
|
Stream<com.vaadin.flow.component.Component> |
getChildren() |
String |
getHeight() |
String |
getMaxHeight() |
String |
getMaxWidth() |
String |
getMinHeight() |
String |
getMinWidth() |
String |
getWidth() |
boolean |
isCloseOnEsc()
Gets whether this dialog can be closed by hitting the esc-key or not.
|
boolean |
isCloseOnOutsideClick()
Gets whether this dialog can be closed by clicking outside of it or not.
|
boolean |
isDraggable()
Gets whether dialog is enabled to be dragged or not.
|
boolean |
isModal()
Gets whether component is set as modal or modeless dialog.
|
boolean |
isOpened()
Gets the open state from the dialog.
|
boolean |
isResizable()
Gets whether dialog is enabled to be resized or not.
|
protected void |
onAttach(com.vaadin.flow.component.AttachEvent attachEvent) |
void |
open()
Opens the dialog.
|
void |
remove(com.vaadin.flow.component.Component... components) |
void |
removeAll() |
void |
removeThemeVariants(DialogVariant... variants)
Removes theme variants from the component.
|
void |
setCloseOnEsc(boolean closeOnEsc)
Sets whether this dialog can be closed by hitting the esc-key or not.
|
void |
setCloseOnOutsideClick(boolean closeOnOutsideClick)
Sets whether this dialog can be closed by clicking outside of it or not.
|
void |
setDraggable(boolean draggable)
Sets whether dialog is enabled to be dragged by the user or not.
|
void |
setHeight(String value) |
void |
setMaxHeight(String value) |
void |
setMaxWidth(String value) |
void |
setMinHeight(String value) |
void |
setMinWidth(String value) |
void |
setModal(boolean modal)
Sets whether component will open modal or modeless dialog.
|
void |
setOpened(boolean opened)
Opens or closes the dialog.
|
void |
setResizable(boolean resizable)
Sets whether dialog can be resized by user or not.
|
void |
setWidth(String value) |
getAriaLabelString, isOpenedBoolean, setAriaLabeladdListener, fireEvent, from, get, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic Dialog()
public Dialog(com.vaadin.flow.component.Component... components)
components - the components inside the dialogadd(Component...)public void setWidth(String value)
setWidth in interface com.vaadin.flow.component.HasSizepublic void setMinWidth(String value)
setMinWidth in interface com.vaadin.flow.component.HasSizepublic void setMaxWidth(String value)
setMaxWidth in interface com.vaadin.flow.component.HasSizepublic void setHeight(String value)
setHeight in interface com.vaadin.flow.component.HasSizepublic void setMinHeight(String value)
setMinHeight in interface com.vaadin.flow.component.HasSizepublic void setMaxHeight(String value)
setMaxHeight in interface com.vaadin.flow.component.HasSizepublic String getWidth()
getWidth in interface com.vaadin.flow.component.HasSizepublic String getMinWidth()
getMinWidth in interface com.vaadin.flow.component.HasSizepublic String getMaxWidth()
getMaxWidth in interface com.vaadin.flow.component.HasSizepublic String getHeight()
getHeight in interface com.vaadin.flow.component.HasSizepublic String getMinHeight()
getMinHeight in interface com.vaadin.flow.component.HasSizepublic String getMaxHeight()
getMaxHeight in interface com.vaadin.flow.component.HasSizepublic com.vaadin.flow.shared.Registration addDialogCloseActionListener(com.vaadin.flow.component.ComponentEventListener<Dialog.DialogCloseActionEvent> listener)
The listener is informed when the user wants to close the dialog by
clicking outside the dialog, or by pressing escape. Then you can decide
whether to close or to keep opened the dialog. It means that dialog won't
be closed automatically unless you call close() method
explicitly in the listener implementation.
NOTE: adding this listener changes behavior of the dialog. Dialog is
closed automatically in case there are no any close listeners. And the
close() method should be called explicitly to close the dialog
in case there are close listeners.
listener - close()public com.vaadin.flow.shared.Registration addResizeListener(com.vaadin.flow.component.ComponentEventListener<Dialog.DialogResizeEvent> listener)
setResizable(boolean)).
Note: By default, the component will sync the width/height values after every resizing.
listener - public void add(com.vaadin.flow.component.Component... components)
The elements in the DOM will not be children of the
<vaadin-dialog> element, but will be inserted into an overlay
that is attached into the <body>.
add in interface com.vaadin.flow.component.HasComponentscomponents - the components to addpublic void remove(com.vaadin.flow.component.Component... components)
remove in interface com.vaadin.flow.component.HasComponentspublic void removeAll()
removeAll in interface com.vaadin.flow.component.HasComponentspublic void addComponentAtIndex(int index,
com.vaadin.flow.component.Component component)
The element in the DOM will not be child of the <vaadin-dialog>
element, but will be inserted into an overlay that is attached into the
<body>.
addComponentAtIndex in interface com.vaadin.flow.component.HasComponentsindex - the index, where the component will be added.component - the component to addpublic boolean isCloseOnEsc()
By default, the dialog is closable with esc.
true if this dialog can be closed with the esc-key,
false otherwisepublic void setCloseOnEsc(boolean closeOnEsc)
By default, the dialog is closable with esc.
closeOnEsc - true to enable closing this dialog with the esc-key,
false to disable itpublic boolean isCloseOnOutsideClick()
By default, the dialog is closable with an outside click.
true if this dialog can be closed by an outside click,
false otherwisepublic void setCloseOnOutsideClick(boolean closeOnOutsideClick)
By default, the dialog is closable with an outside click.
closeOnOutsideClick - true to enable closing this dialog with an outside
click, false to disable itpublic void open()
Note: You don't need to add the dialog component anywhere before opening
it. Since <vaadin-dialog>'s location in the DOM doesn't really
matter, opening a dialog will automatically add it to the <body>
if necessary.
public void close()
Note: This method also removes the dialog component from the DOM after closing it, unless you have added the component manually.
public void setModal(boolean modal)
Note: When dialog is set to be modeless, then it's up to you to provide
means for it to be closed (eg. a button that calls
close()). The reason being that a modeless dialog allows
user to interact with the interface under it and won't be closed by
clicking outside or the ESC key.
modal - false to enable dialog to open as modeless modal,
true otherwise.public boolean isModal()
true if modal dialog (default), false otherwise.public void setDraggable(boolean draggable)
To allow an element inside the dialog to be dragged by the user (for
instance, a header inside the dialog), a class "draggable" can be
added to it (see HasStyle.addClassName(String)).
Note: If draggable is enabled and dialog is opened without first being explicitly attached to a parent, then it won't restore its last position in the case the user closes and opens it again. Reason being that a self attached dialog is removed from the DOM when it's closed and position is not synched.
draggable - true to enable dragging of the dialog, false
otherwisepublic boolean isDraggable()
true if dragging is enabled, false otherwise
(default).public void setResizable(boolean resizable)
resizable - true to enabled resizing of the dialog, false
otherwise.public boolean isResizable()
true if resizing is enabled, falsoe otherwiser
(default).public void setOpened(boolean opened)
Note: You don't need to add the dialog component anywhere before opening
it. Since <vaadin-dialog>'s location in the DOM doesn't really
matter, opening a dialog will automatically add it to the <body>
if necessary.
setOpened in class GeneratedVaadinDialog<Dialog>opened - true to open the dialog, false to close itpublic boolean isOpened()
opened property from the dialogpublic Stream<com.vaadin.flow.component.Component> getChildren()
getChildren in class com.vaadin.flow.component.Componentpublic com.vaadin.flow.shared.Registration addOpenedChangeListener(com.vaadin.flow.component.ComponentEventListener<GeneratedVaadinDialog.OpenedChangeEvent<Dialog>> listener)
opened-changed events.addOpenedChangeListener in class GeneratedVaadinDialog<Dialog>listener - the listenerRegistration for removing the event listenerpublic com.vaadin.flow.shared.Registration addAttachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.AttachEvent> listener)
Note: To listen for opening the dialog, you should use
addOpenedChangeListener(ComponentEventListener).
addAttachListener in interface com.vaadin.flow.component.AttachNotifierpublic com.vaadin.flow.shared.Registration addDetachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.DetachEvent> listener)
Note: To listen for closing the dialog, you should use
addOpenedChangeListener(ComponentEventListener), as the
component is not necessarily removed from the DOM when closing.
addDetachListener in interface com.vaadin.flow.component.DetachNotifierprotected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
onAttach in class com.vaadin.flow.component.Componentpublic void addThemeVariants(DialogVariant... variants)
variants - theme variants to addpublic void removeThemeVariants(DialogVariant... variants)
variants - theme variants to removeCopyright © 2025. All rights reserved.