Class MasterDetailLayout
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.masterdetaillayout.MasterDetailLayout
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.router.RouterLayout,Serializable
@Tag("vaadin-master-detail-layout")
@NpmPackage(value="@vaadin/master-detail-layout",
version="25.2.0-alpha10")
@JsModule("@vaadin/master-detail-layout/src/vaadin-master-detail-layout.js")
public class MasterDetailLayout
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasSize, com.vaadin.flow.router.RouterLayout
MasterDetailLayout is a component for building UIs with a master (or primary)
area and a detail (or secondary) area that is displayed next to, or overlaid
on top of, the master area, depending on configuration and viewport size.
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEvent that is fired when the backdrop of the details overlay is clicked.static classEvent that is fired when the Escape key is pressed within the details area.static enumSupported orientation values forMasterDetailLayout.static enumSupported overlay containment values forMasterDetailLayout. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty Master Detail Layout.MasterDetailLayout(float masterSize, com.vaadin.flow.component.Unit masterUnit, float detailSize, com.vaadin.flow.component.Unit detailUnit) Creates a Master Detail Layout with the given master and detail sizes.MasterDetailLayout(String masterSize, String detailSize) Creates a Master Detail Layout with the given master and detail sizes. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddBackdropClickListener(com.vaadin.flow.component.ComponentEventListener<MasterDetailLayout.BackdropClickEvent> listener) Adds a listener for when the backdrop of the details overlay is clicked.com.vaadin.flow.shared.RegistrationaddDetailEscapePressListener(com.vaadin.flow.component.ComponentEventListener<MasterDetailLayout.DetailEscapePressEvent> listener) Adds a listener for when the Escape key is pressed within the details area.com.vaadin.flow.component.ComponentGets the component currently in the detail area.com.vaadin.flow.component.ComponentGets the component currently in the detail placeholder area.Gets the size of the detail area.com.vaadin.flow.component.ComponentGets the component currently in the master area.Gets the size of the master area.Gets the orientation of the layout.Gets the overlay containment of the layout.Gets the size of the detail area when shown as an overlay.booleanGets whether the layout animation is enabled.booleanGets whether the detail area expands to fill available space.booleanGets whether the master area expands to fill available space.booleanGets whether the layout forces the detail area to be shown as an overlay, even if there is enough space for master and detail to be shown next to each other using the default (split) mode.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidremoveRouterLayoutContent(com.vaadin.flow.component.HasElement oldContent) voidsetAnimationEnabled(boolean enabled) Sets whether the layout animation is enabled.voidsetDetail(com.vaadin.flow.component.Component component) Sets the component to be displayed in the detail area.voidsetDetailPlaceholder(com.vaadin.flow.component.Component component) Sets the component to be displayed in the detail placeholder area.voidsetDetailSize(float size, com.vaadin.flow.component.Unit unit) Sets the size of the detail area in CSS length units.voidsetDetailSize(float size, com.vaadin.flow.component.Unit unit, boolean expand) Sets the size of the detail area in CSS length units and whether the detail area expands to fill available space.voidsetDetailSize(float size, com.vaadin.flow.component.Unit unit, boolean expand, float overlaySize, com.vaadin.flow.component.Unit overlayUnit) Sets the size of the detail area, whether the detail area expands to fill available space, and the size of the detail area when shown as an overlay.voidsetDetailSize(float size, com.vaadin.flow.component.Unit unit, float overlaySize, com.vaadin.flow.component.Unit overlayUnit) Sets the size of the detail area and the size of the detail area when shown as an overlay, both in CSS length units.voidsetDetailSize(String size) Sets the size of the detail area in CSS length units.voidsetDetailSize(String size, boolean expand) Sets the size of the detail area in CSS length units and whether the detail area expands to fill available space.voidsetDetailSize(String size, boolean expand, String overlaySize) Sets the size of the detail area in CSS length units, whether the detail area expands to fill available space, and the size of the detail area when shown as an overlay.voidsetDetailSize(String size, String overlaySize) Sets the size of the detail area and the size of the detail area when shown as an overlay, both in CSS length units.voidsetExpandDetail(boolean expandDetail) Sets whether the detail area expands to fill available space.voidsetExpandMaster(boolean expandMaster) Sets whether the master area expands to fill available space.voidsetForceOverlay(boolean forceOverlay) Sets whether the layout forces the detail area to be shown as an overlay, even if there is enough space for master and detail to be shown next to each other using the default (split) mode.voidsetMaster(com.vaadin.flow.component.Component component) Sets the component to be displayed in the master area.voidsetMasterSize(float size, com.vaadin.flow.component.Unit unit) Sets the size of the master area in CSS length units.voidsetMasterSize(float size, com.vaadin.flow.component.Unit unit, boolean expand) Sets the size of the master area in CSS length units and whether the master area expands to fill available space.voidsetMasterSize(String size) Sets the size of the master area in CSS length units.voidsetMasterSize(String size, boolean expand) Sets the size of the master area in CSS length units and whether the master area expands to fill available space.voidsetOrientation(MasterDetailLayout.Orientation orientation) Sets the orientation of the layout.voidsetOverlayContainment(MasterDetailLayout.OverlayContainment overlayContainment) Sets the containment of the detail area when the layout is in overlay mode.voidsetOverlaySize(float size, com.vaadin.flow.component.Unit unit) Sets the size of the detail area when shown as an overlay.voidsetOverlaySize(String size) Sets the size of the detail area when shown as an overlay.voidshowRouterLayoutContent(com.vaadin.flow.component.HasElement content) Methods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
MASTER_SLOT
- See Also:
-
DETAIL_PLACEHOLDER_SLOT
- See Also:
-
-
Constructor Details
-
MasterDetailLayout
public MasterDetailLayout()Creates an empty Master Detail Layout. -
MasterDetailLayout
Creates a Master Detail Layout with the given master and detail sizes.- Parameters:
masterSize- the size of the master area in CSS length unitsdetailSize- the size of the detail area in CSS length units
-
MasterDetailLayout
public MasterDetailLayout(float masterSize, com.vaadin.flow.component.Unit masterUnit, float detailSize, com.vaadin.flow.component.Unit detailUnit) Creates a Master Detail Layout with the given master and detail sizes.- Parameters:
masterSize- the size of the master areamasterUnit- the unit for the master sizedetailSize- the size of the detail areadetailUnit- the unit for the detail size
-
-
Method Details
-
getMaster
public com.vaadin.flow.component.Component getMaster()Gets the component currently in the master area.- Returns:
- the component in the master area, or
nullif there is no component in the master area
-
setMaster
public void setMaster(com.vaadin.flow.component.Component component) Sets the component to be displayed in the master area.- Parameters:
component- the component to display in the master area, notnull
-
getDetail
public com.vaadin.flow.component.Component getDetail()Gets the component currently in the detail area.- Returns:
- the component in the detail area, or
nullif there is no component in the detail area
-
setDetail
public void setDetail(com.vaadin.flow.component.Component component) Sets the component to be displayed in the detail area. The details area is automatically shown when the detail component is set, and hidden when the detail component is removed by setting it tonull.- Parameters:
component- the component to display in the detail area, ornullto clear the detail area
-
getDetailPlaceholder
public com.vaadin.flow.component.Component getDetailPlaceholder()Gets the component currently in the detail placeholder area.- Returns:
- the component in the detail placeholder area, or
nullif there is no component in the detail placeholder area
-
setDetailPlaceholder
public void setDetailPlaceholder(com.vaadin.flow.component.Component component) Sets the component to be displayed in the detail placeholder area. The placeholder is shown when no detail content is set, and is hidden when the layout is in overlay mode. Unlike the detail content, the placeholder does not become an overlay when there is not enough space.- Parameters:
component- the component to display in the detail placeholder area, ornullto clear the detail placeholder area
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-
getMasterSize
Gets the size of the master area.- Returns:
- the size of the master area in CSS length units, or
nullif the size is not set
-
setMasterSize
Sets the size of the master area in CSS length units. If there is not enough space to show master and detail areas next to each other, the detail area is shown as an overlay. Defaults to 30em.- Parameters:
size- the size of the master area in CSS length units
-
setMasterSize
public void setMasterSize(float size, com.vaadin.flow.component.Unit unit) Sets the size of the master area in CSS length units. If there is not enough space to show master and detail areas next to each other, the detail area is shown as an overlay. Defaults to 30em.- Parameters:
size- the size of the master areaunit- the unit
-
setMasterSize
Sets the size of the master area in CSS length units and whether the master area expands to fill available space.- Parameters:
size- the size of the master area in CSS length unitsexpand-trueto expand the master area,falseotherwise- See Also:
-
setMasterSize
public void setMasterSize(float size, com.vaadin.flow.component.Unit unit, boolean expand) Sets the size of the master area in CSS length units and whether the master area expands to fill available space.- Parameters:
size- the size of the master areaunit- the unitexpand-trueto expand the master area,falseotherwise- See Also:
-
getDetailSize
Gets the size of the detail area.- Returns:
- the size of the detail area in CSS length units, or
nullif the size is not set
-
setDetailSize
Sets the size of the detail area in CSS length units. When there is not enough space to show master and detail areas next to each other, the detail area is shown as an overlay.If not specified, the size is determined automatically by measuring the detail content whenever new content is provided via
setDetail(com.vaadin.flow.component.Component). The measured intrinsic size is then cached until the nextsetDetail(com.vaadin.flow.component.Component)call.- Parameters:
size- the size of the detail area in CSS length units
-
setDetailSize
public void setDetailSize(float size, com.vaadin.flow.component.Unit unit) Sets the size of the detail area in CSS length units. When there is not enough space to show master and detail areas next to each other, the detail area is shown as an overlay.If not specified, the size is determined automatically by measuring the detail content whenever new content is provided via
setDetail(com.vaadin.flow.component.Component). The measured intrinsic size is then cached until the nextsetDetail(com.vaadin.flow.component.Component)call.- Parameters:
size- the size of the detail areaunit- the unit
-
setDetailSize
Sets the size of the detail area in CSS length units and whether the detail area expands to fill available space.- Parameters:
size- the size of the detail area in CSS length unitsexpand-trueto expand the detail area,falseotherwise- See Also:
-
setDetailSize
public void setDetailSize(float size, com.vaadin.flow.component.Unit unit, boolean expand) Sets the size of the detail area in CSS length units and whether the detail area expands to fill available space.- Parameters:
size- the size of the detail areaunit- the unitexpand-trueto expand the detail area,falseotherwise- See Also:
-
setDetailSize
Sets the size of the detail area and the size of the detail area when shown as an overlay, both in CSS length units.- Parameters:
size- the size of the detail area in CSS length unitsoverlaySize- the overlay size in CSS length units- See Also:
-
setDetailSize
public void setDetailSize(float size, com.vaadin.flow.component.Unit unit, float overlaySize, com.vaadin.flow.component.Unit overlayUnit) Sets the size of the detail area and the size of the detail area when shown as an overlay, both in CSS length units.- Parameters:
size- the size of the detail areaunit- the unit for the detail sizeoverlaySize- the overlay sizeoverlayUnit- the unit for the overlay size- See Also:
-
setDetailSize
Sets the size of the detail area in CSS length units, whether the detail area expands to fill available space, and the size of the detail area when shown as an overlay.- Parameters:
size- the size of the detail area in CSS length unitsexpand-trueto expand the detail area,falseotherwiseoverlaySize- the overlay size in CSS length units- See Also:
-
setDetailSize
public void setDetailSize(float size, com.vaadin.flow.component.Unit unit, boolean expand, float overlaySize, com.vaadin.flow.component.Unit overlayUnit) Sets the size of the detail area, whether the detail area expands to fill available space, and the size of the detail area when shown as an overlay.- Parameters:
size- the size of the detail areaunit- the unit for the detail sizeexpand-trueto expand the detail area,falseotherwiseoverlaySize- the overlay sizeoverlayUnit- the unit for the overlay size- See Also:
-
getOrientation
Gets the orientation of the layout. Defaults toMasterDetailLayout.Orientation.HORIZONTAL.- Returns:
- the orientation
-
setOrientation
Sets the orientation of the layout. Defines how master and detail areas are shown next to each other, and whether size is applied as width or height.- Parameters:
orientation- the orientation
-
getOverlayContainment
Gets the overlay containment of the layout. Defaults toMasterDetailLayout.OverlayContainment.LAYOUT.- Returns:
- the overlay containment
-
setOverlayContainment
Sets the containment of the detail area when the layout is in overlay mode. When set toMasterDetailLayout.OverlayContainment.LAYOUT, the overlay is confined to the layout. When set toMasterDetailLayout.OverlayContainment.PAGE, the overlay is confined to the browser's viewport. Defaults toMasterDetailLayout.OverlayContainment.LAYOUT.- Parameters:
overlayContainment- the overlay containment
-
getOverlaySize
Gets the size of the detail area when shown as an overlay.- Returns:
- the overlay size in CSS length units, or
nullif the overlay size is not set
-
setOverlaySize
Sets the size of the detail area when shown as an overlay. When not set, falls back to the detail size. Set to"100%"to make the detail cover the full layout.- Parameters:
size- the overlay size in CSS length units
-
setOverlaySize
public void setOverlaySize(float size, com.vaadin.flow.component.Unit unit) Sets the size of the detail area when shown as an overlay. When not set, falls back to the detail size. Set to100withto make the detail cover the full layout.invalid reference
Unit#PCT- Parameters:
size- the overlay sizeunit- the unit
-
isExpandMaster
public boolean isExpandMaster()Gets whether the master area expands to fill available space. Defaults tofalse.- Returns:
trueif the master area expands,falseotherwise
-
setExpandMaster
public void setExpandMaster(boolean expandMaster) Sets whether the master area expands to fill available space. When bothsetExpandMaster(boolean)andsetExpandDetail(boolean)are set totrue, the master and detail areas share the available space equally.- Parameters:
expandMaster-trueto expand the master area,falseotherwise
-
isExpandDetail
public boolean isExpandDetail()Gets whether the detail area expands to fill available space. Defaults tofalse.- Returns:
trueif the detail area expands,falseotherwise
-
setExpandDetail
public void setExpandDetail(boolean expandDetail) Sets whether the detail area expands to fill available space. When bothsetExpandMaster(boolean)andsetExpandDetail(boolean)are set totrue, the master and detail areas share the available space equally.- Parameters:
expandDetail-trueto expand the detail area,falseotherwise
-
isForceOverlay
public boolean isForceOverlay()Gets whether the layout forces the detail area to be shown as an overlay, even if there is enough space for master and detail to be shown next to each other using the default (split) mode.- Returns:
trueif the overlay mode is enforced,falseotherwise
-
setForceOverlay
public void setForceOverlay(boolean forceOverlay) Sets whether the layout forces the detail area to be shown as an overlay, even if there is enough space for master and detail to be shown next to each other using the default (split) mode.- Parameters:
forceOverlay-trueif the overlay mode is enforced,falseotherwise
-
isAnimationEnabled
public boolean isAnimationEnabled()Gets whether the layout animation is enabled.- Returns:
trueif the animation is enabled,falseotherwise
-
setAnimationEnabled
public void setAnimationEnabled(boolean enabled) Sets whether the layout animation is enabled.- Parameters:
enabled-trueif the animation is enabled,falseotherwise
-
addBackdropClickListener
public com.vaadin.flow.shared.Registration addBackdropClickListener(com.vaadin.flow.component.ComponentEventListener<MasterDetailLayout.BackdropClickEvent> listener) Adds a listener for when the backdrop of the details overlay is clicked. The backdrop is the area outside the detail area when it is shown in overlay mode. Can be used to hide the details when the backdrop is clicked.- Parameters:
listener- the listener to add, notnull- Returns:
- a registration for removing the listener
-
addDetailEscapePressListener
public com.vaadin.flow.shared.Registration addDetailEscapePressListener(com.vaadin.flow.component.ComponentEventListener<MasterDetailLayout.DetailEscapePressEvent> listener) Adds a listener for when the Escape key is pressed within the details area. Can be used to hide the details when the Escape key is pressed.- Parameters:
listener- the listener to add, notnull- Returns:
- a registration for removing the listener
-
showRouterLayoutContent
public void showRouterLayoutContent(com.vaadin.flow.component.HasElement content) - Specified by:
showRouterLayoutContentin interfacecom.vaadin.flow.router.RouterLayout
-
removeRouterLayoutContent
public void removeRouterLayoutContent(com.vaadin.flow.component.HasElement oldContent) - Specified by:
removeRouterLayoutContentin interfacecom.vaadin.flow.router.RouterLayout
-