Interface HasItems<E extends Element,B extends TypedBuilder<E,B>,S>

Type Parameters:
E - the element type of the main component
B - the builder type of the main component
S - the type of the subcomponent (representing an item)

record User(String id, String name, boolean valid) {}

// construction time
List<User> users = emptyList();
DataList dl = dataList()
        .addItems(users, user -> dataListItem(user.id())
                .store("user", user)
                .addCell(dataListCell().icon(user()))
                .addCell(dataListCell()
                        .add(span()
                                .id(user.id())
                                .text(user.name()))));

// later, responding to an event or something similar
for (DataListItem item : dl) {
    User user = item.get("user");
    item.toggle("invalid-user", !user.valid());
}
All Superinterfaces:
IsElement<E>, Iterable<S>, TypedBuilder<E,B>
All Known Implementing Classes:
Accordion, ActionList, ActionListGroup, AlertGroup, Breadcrumb, DataList, DescriptionList, ExpandableNavigationGroup, Form, JumpLinks, JumpLinksList, LabelGroup, List, MenuList, Navigation, NavigationGroup, ProgressStepper, SimpleList, SimpleListGroup, Tabs, Tbody, ToggleGroup, ToolbarContent, ToolbarFilterContent, ToolbarGroup, ToolbarToggleGroup, Tr, TreeView, TreeViewItem

public interface HasItems<E extends Element,B extends TypedBuilder<E,B>,S> extends Iterable<S>, TypedBuilder<E,B>, IsElement<E>
The HasItems interface represents a component that can contain a collection of items. It provides methods for adding, removing, and manipulating items within the component.

Often the child components implement ComponentContext and HasIdentifier.

  • Method Details

    • addItems

      default <T> B addItems(Iterable<T> items, Function<T,S> display)
    • addItem

      default B addItem(S item)
    • add

      B add(S item)
    • items

      default List<S> items()
    • size

      int size()
    • isEmpty

      boolean isEmpty()
    • contains

      boolean contains(String identifier)
    • item

      S item(String identifier)
    • clear

      void clear()