Directory

← Back

Repeater

Controller for repeating child components based on a list of items.

Author

Rating

Popularity

<100

A controller for multiple repeated items in a container. The repeater maintains a list of components in a container based on a corresponding list of data items.

When given an updated list, it takes care of adding, removing and reordering the components efficiently without the help of fine-grained information about the changes in the list.

Sample code


// Callbacks for creating a new panel for an item and to update an existing one
Repeater<Person> repeater = new Repeater<>(container,
    PersonPanel::new,
    PersonPanel::setPerson);

ListDataProvider<Person> dataProvider = DataProvider.ofCollection(persons);
repeater.setDataProvider(dataProvider);

new Button("Sort by title", event -> {
  // Repeater automatically re-renders when the data provider changes
  dataProvider.setSortOrder(Person::getTitle, SortDirection.ASCENDING);
}
List<Peson> persons = loadPersons();

// Callbacks for creating a new panel for an item and to update an existing one
Repeater<Person> repeater = new Repeater<>(container,
    PersonPanel::new,
    PersonPanel::setPerson);
repeater.showItems(persons);

new Button("Remove first person", event -> {
  persons.remove(0);
  // Call showItems with a new or an updated list to update the UI
  repeater.showItems(persons);
});

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Released
2020-03-27
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 10+
Browser
Browser Independent

Repeater - Vaadin Add-on Directory

Controller for repeating child components based on a list of items. Repeater - Vaadin Add-on Directory
A controller for multiple repeated items in a container. The repeater maintains a list of components in a container based on a corresponding list of data items. When given an updated list, it takes care of adding, removing and reordering the components efficiently without the help of fine-grained information about the changes in the list.
View on GitHub

Repeater version 1.0.0

Online