Class Dialog
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.dialog.GeneratedVaadinDialog<Dialog>
-
- com.vaadin.flow.component.dialog.Dialog
-
- 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.HasSize,com.vaadin.flow.component.HasTheme,Serializable
@JsModule("./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.HasThemeServer-side component for the<vaadin-dialog>element.- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDialog.DialogCloseActionEvent`vaadin-dialog-close-action` is sent when the user clicks outside the overlay or presses the escape key.static classDialog.DialogResizeEvent`resize` event is sent when the user finishes resizing the overlay.-
Nested classes/interfaces inherited from class com.vaadin.flow.component.dialog.GeneratedVaadinDialog
GeneratedVaadinDialog.OpenedChangeEvent<R extends GeneratedVaadinDialog<R>>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(com.vaadin.flow.component.Component... components)Adds the given components into this dialog.com.vaadin.flow.shared.RegistrationaddAttachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.AttachEvent> listener)voidaddComponentAtIndex(int index, com.vaadin.flow.component.Component component)Adds the given component into this dialog at the given index.com.vaadin.flow.shared.RegistrationaddDetachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.DetachEvent> listener)com.vaadin.flow.shared.RegistrationaddDialogCloseActionListener(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.RegistrationaddOpenedChangeListener(com.vaadin.flow.component.ComponentEventListener<GeneratedVaadinDialog.OpenedChangeEvent<Dialog>> listener)Add a lister for event fired by theopened-changedevents.com.vaadin.flow.shared.RegistrationaddResizeListener(com.vaadin.flow.component.ComponentEventListener<Dialog.DialogResizeEvent> listener)Adds a listener that is called after user finishes resizing the overlay.voidaddThemeVariants(DialogVariant... variants)Adds theme variants to the component.voidclose()Closes the dialog.Stream<com.vaadin.flow.component.Component>getChildren()StringgetHeight()StringgetMaxHeight()StringgetMaxWidth()StringgetMinHeight()StringgetMinWidth()StringgetWidth()booleanisCloseOnEsc()Gets whether this dialog can be closed by hitting the esc-key or not.booleanisCloseOnOutsideClick()Gets whether this dialog can be closed by clicking outside of it or not.booleanisDraggable()Gets whether dialog is enabled to be dragged or not.booleanisModal()Gets whether component is set as modal or modeless dialog.booleanisOpened()Gets the open state from the dialog.booleanisResizable()Gets whether dialog is enabled to be resized or not.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent)voidopen()Opens the dialog.voidremove(com.vaadin.flow.component.Component... components)voidremoveAll()voidremoveThemeVariants(DialogVariant... variants)Removes theme variants from the component.voidsetCloseOnEsc(boolean closeOnEsc)Sets whether this dialog can be closed by hitting the esc-key or not.voidsetCloseOnOutsideClick(boolean closeOnOutsideClick)Sets whether this dialog can be closed by clicking outside of it or not.voidsetDraggable(boolean draggable)Sets whether dialog is enabled to be dragged by the user or not.voidsetHeight(String value)voidsetMaxHeight(String value)voidsetMaxWidth(String value)voidsetMinHeight(String value)voidsetMinWidth(String value)voidsetModal(boolean modal)Sets whether component will open modal or modeless dialog.voidsetOpened(boolean opened)Opens or closes the dialog.voidsetResizable(boolean resizable)Sets whether dialog can be resized by user or not.voidsetVisible(boolean visible)Set the visibility of the dialog.voidsetWidth(String value)-
Methods inherited from class com.vaadin.flow.component.dialog.GeneratedVaadinDialog
getAriaLabelString, isOpenedBoolean, setAriaLabel
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
Dialog
public Dialog()
Creates an empty dialog.
-
Dialog
public Dialog(com.vaadin.flow.component.Component... components)
Creates a dialog with given components inside.- Parameters:
components- the components inside the dialog- See Also:
add(Component...)
-
-
Method Detail
-
setWidth
public void setWidth(String value)
- Specified by:
setWidthin interfacecom.vaadin.flow.component.HasSize
-
setMinWidth
public void setMinWidth(String value)
- Specified by:
setMinWidthin interfacecom.vaadin.flow.component.HasSize
-
setMaxWidth
public void setMaxWidth(String value)
- Specified by:
setMaxWidthin interfacecom.vaadin.flow.component.HasSize
-
setHeight
public void setHeight(String value)
- Specified by:
setHeightin interfacecom.vaadin.flow.component.HasSize
-
setMinHeight
public void setMinHeight(String value)
- Specified by:
setMinHeightin interfacecom.vaadin.flow.component.HasSize
-
setMaxHeight
public void setMaxHeight(String value)
- Specified by:
setMaxHeightin interfacecom.vaadin.flow.component.HasSize
-
getWidth
public String getWidth()
- Specified by:
getWidthin interfacecom.vaadin.flow.component.HasSize
-
getMinWidth
public String getMinWidth()
- Specified by:
getMinWidthin interfacecom.vaadin.flow.component.HasSize
-
getMaxWidth
public String getMaxWidth()
- Specified by:
getMaxWidthin interfacecom.vaadin.flow.component.HasSize
-
getHeight
public String getHeight()
- Specified by:
getHeightin interfacecom.vaadin.flow.component.HasSize
-
getMinHeight
public String getMinHeight()
- Specified by:
getMinHeightin interfacecom.vaadin.flow.component.HasSize
-
getMaxHeight
public String getMaxHeight()
- Specified by:
getMaxHeightin interfacecom.vaadin.flow.component.HasSize
-
addDialogCloseActionListener
public 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.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.- Parameters:
listener-- Returns:
- registration for removal of listener
- See Also:
close()
-
addResizeListener
public 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. It is called only if resizing is enabled (seesetResizable(boolean)).Note: By default, the component will sync the width/height values after every resizing.
- Parameters:
listener-- Returns:
- registration for removal of listener
-
add
public void add(com.vaadin.flow.component.Component... components)
Adds the given components into this dialog.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>.- Specified by:
addin interfacecom.vaadin.flow.component.HasComponents- Parameters:
components- the components to add
-
remove
public void remove(com.vaadin.flow.component.Component... components)
- Specified by:
removein interfacecom.vaadin.flow.component.HasComponents
-
removeAll
public void removeAll()
- Specified by:
removeAllin interfacecom.vaadin.flow.component.HasComponents
-
addComponentAtIndex
public void addComponentAtIndex(int index, com.vaadin.flow.component.Component component)Adds the given component into this dialog at the given index.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>.- Specified by:
addComponentAtIndexin interfacecom.vaadin.flow.component.HasComponents- Parameters:
index- the index, where the component will be added.component- the component to add
-
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
-
isCloseOnOutsideClick
public boolean isCloseOnOutsideClick()
Gets whether this dialog can be closed by clicking outside of it or not.By default, the dialog is closable with an outside click.
- Returns:
trueif this dialog can be closed by an outside click,falseotherwise
-
setCloseOnOutsideClick
public void setCloseOnOutsideClick(boolean closeOnOutsideClick)
Sets whether this dialog can be closed by clicking outside of it or not.By default, the dialog is closable with an outside click.
- Parameters:
closeOnOutsideClick-trueto enable closing this dialog with an outside click,falseto disable it
-
open
public void open()
Opens the dialog.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.
-
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.
-
setModal
public void setModal(boolean modal)
Sets whether component will open modal or modeless dialog.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.- Parameters:
modal-falseto enable dialog to open as modeless modal,trueotherwise.
-
isModal
public boolean isModal()
Gets whether component is set as modal or modeless dialog.- Returns:
trueif modal dialog (default),falseotherwise.
-
setDraggable
public void setDraggable(boolean draggable)
Sets whether dialog is enabled to be dragged by the user or not.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 (seeHasStyle.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.
- Parameters:
draggable-trueto enable dragging of the dialog,falseotherwise
-
isDraggable
public boolean isDraggable()
Gets whether dialog is enabled to be dragged or not.- Returns:
trueif dragging is enabled,falseotherwise (default).
-
setResizable
public void setResizable(boolean resizable)
Sets whether dialog can be resized by user or not.- Parameters:
resizable-trueto enabled resizing of the dialog,falseotherwise.
-
isResizable
public boolean isResizable()
Gets whether dialog is enabled to be resized or not.- Returns:
trueif resizing is enabled,falsoeotherwiser (default).
-
setVisible
public void setVisible(boolean visible)
Set the visibility of the dialog.For a modal dialog the server-side modality will be removed when dialog is not visible so that interactions can be made in the application.
- Overrides:
setVisiblein classcom.vaadin.flow.component.Component- Parameters:
visible- dialog visibility- See Also:
Component.setVisible(boolean)
-
setOpened
public void setOpened(boolean opened)
Opens or closes the dialog.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.- Overrides:
setOpenedin classGeneratedVaadinDialog<Dialog>- Parameters:
opened-trueto open the dialog,falseto close it
-
isOpened
public boolean isOpened()
Gets the open state from the dialog.- Returns:
- the
openedproperty from the dialog
-
getChildren
public Stream<com.vaadin.flow.component.Component> getChildren()
- Overrides:
getChildrenin classcom.vaadin.flow.component.Component
-
addOpenedChangeListener
public com.vaadin.flow.shared.Registration addOpenedChangeListener(com.vaadin.flow.component.ComponentEventListener<GeneratedVaadinDialog.OpenedChangeEvent<Dialog>> listener)
Add a lister for event fired by theopened-changedevents.- Overrides:
addOpenedChangeListenerin classGeneratedVaadinDialog<Dialog>- Parameters:
listener- the listener- Returns:
- a
Registrationfor removing the event listener
-
addAttachListener
public 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).- Specified by:
addAttachListenerin interfacecom.vaadin.flow.component.AttachNotifier
-
addDetachListener
public 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.- Specified by:
addDetachListenerin interfacecom.vaadin.flow.component.DetachNotifier
-
addThemeVariants
public void addThemeVariants(DialogVariant... variants)
Adds theme variants to the component.- Parameters:
variants- theme variants to add
-
removeThemeVariants
public void removeThemeVariants(DialogVariant... variants)
Removes theme variants from the component.- Parameters:
variants- theme variants to remove
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
- Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
-