Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Select all itens on a Table
How can I implement a button to select or unselect all itens on a Mult Select Table?
Valder
Hi,
You can addListener to the button. And in the buttonClick method, you can retrieve all the itemIds from the table; then put them into a set; finally set it to table.setValue(set).
To unselect the values, just do the following: table.setValue(null);
Button button = new Button("Test");
public void buildPanel(){
this.addComponent(button);
button.addListener(this);
}
public void buttonClick (Button.ClickEvent event) {
HashSet set = new HashSet();
Iterator iterator = table.getItemIds().iterator();
while (iterator.hasNext()) {
Message msg = (Message) iterator.next();
set.add(msg);
}
table.setValue(set);
}
button.addListener(new ClickListener()
{
@Override
public void buttonClick(ClickEvent event)
{
Collection<?> vals = (Collection<?>) table.getValue();
if(vals.isEmpty())
{
table.setValue(table.getItemIds());
}
else table.setValue(null);
}
});