I am using Vaadin 14.1.23 with a ListBox filled with items. Now I was trying to add a selection listener for single selections as I want to trigger some events once an items is selected (tagged with the green tick). However, I am not able to find any possibility to add such listener. Do I need to create my own listbox component to make this possible? Also couldn’t find any example online.
You could add a valueChangeListener for this.
listBox.addValueChangeListener(event -> {
Notification.show("Listbox selection was changed to " + event.getValue());
});
Kaspar Scherrer:
You could add a valueChangeListener for this.listBox.addValueChangeListener(event -> { Notification.show("Listbox selection was changed to " + event.getValue()); });
I swear I used that before and for some reason it didn’t work. So now I tried again and it stuns me that it works now… very oddy.
But many thanks making me try again with this code!