Interface HasComponents
- All Superinterfaces:
HasElement
,HasEnabled
,Serializable
- All Known Subinterfaces:
FlexComponent
,HasItemComponents<T>
,HasItemsAndComponents<T>
,HasOrderedComponents
- All Known Implementing Classes:
AccordionPanel
,Anchor
,Article
,Aside
,Board
,CheckboxGroup
,ConfirmDialog
,ContextMenu
,ContextMenuBase
,DescriptionList
,DescriptionList.Description
,DescriptionList.Term
,Details
,Dialog
,Div
,Emphasis
,FlexLayout
,Footer
,FormLayout
,FormLayout.FormItem
,GridContextMenu
,GridMenuItem
,H1
,H2
,H3
,H4
,H5
,H6
,Header
,HorizontalLayout
,HtmlContainer
,HtmlObject
,Image
,Label
,ListBox
,ListBoxBase
,ListItem
,Main
,MenuItem
,MenuItemBase
,MultiSelectListBox
,NativeButton
,NativeDetails.Summary
,NativeLabel
,Nav
,Notification
,OrderedList
,Paragraph
,Pre
,RouterLink
,Row
,Section
,Select
,Span
,Tab
,UI
,UnorderedList
,VerticalLayout
,WebComponentUI
Component
in itself provides basic support for child components that
are manually added as children of an element belonging to the component. This
interface provides an explicit API for components that explicitly supports
adding and removing arbitrary child components.
HasComponents
is generally implemented by layouts or components whose
primary function is to host child components. It isn't for example
implemented by non-layout components such as fields.
The default implementations assume that children are attached to
HasElement.getElement()
. Override all methods in this interface if the
components should be added to some other element.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Adds the given components as children of this component.default void
Add the given text as a child of this component.default void
add
(Collection<Component> components) Adds the given components as children of this component.default void
addComponentAsFirst
(Component component) Adds the given component as the first child of this component.default void
addComponentAtIndex
(int index, Component component) Adds the given component as child of this component at the specific index.default void
Removes the given child components from this component.default void
remove
(Collection<Component> components) Removes the given child components from this component.default void
Removes all contents from this component, this includes child components, text content as well as child elements that have been added directly to this component using theElement
API.Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Method Details
-
add
Adds the given components as children of this component.In case any of the specified components has already been added to another parent, it will be removed from there and added to this one.
- Parameters:
components
- the components to add
-
add
Adds the given components as children of this component.In case any of the specified components has already been added to another parent, it will be removed from there and added to this one.
- Parameters:
components
- the components to add
-
add
Add the given text as a child of this component.- Parameters:
text
- the text to add, notnull
-
remove
Removes the given child components from this component.- Parameters:
components
- the components to remove- Throws:
IllegalArgumentException
- if there is a component whose nonnull
parent is not this component
-
remove
Removes the given child components from this component.- Parameters:
components
- the components to remove- Throws:
IllegalArgumentException
- if there is a component whose nonnull
parent is not this component
-
removeAll
default void removeAll()Removes all contents from this component, this includes child components, text content as well as child elements that have been added directly to this component using theElement
API. it also removes the children that were added only at the client-side. -
addComponentAtIndex
Adds the given component as child of this component at the specific index.In case the specified component has already been added to another parent, it will be removed from there and added to this one.
- Parameters:
index
- the index, where the component will be added. The index must be non-negative and may not exceed the children countcomponent
- the component to add, value should not be null
-
addComponentAsFirst
Adds the given component as the first child of this component.In case the specified component has already been added to another parent, it will be removed from there and added to this one.
- Parameters:
component
- the component to add, value should not be null
-