ComboBox filter listener

Hello everyones,

For one project I need to use in a combobox a table with more thant 6.000.000 records, and I’m not happy with the current dataprovider lazy loading, because user will never browse the entie table.

What I want to do is at the creation of the combobox, initialising the List of item with the first 2000 records, and when a filter character is typed in the combobox, reloading the List from SQL with the filter applied, but again the first 2000 result only, and so one until the query result number is less than theses 2000 records, then I let the combo box filter finishing the job.

Is there a methode available that I can trap any characters typed in the text field of the combobox?


For different Reasons i also tryed to fetch the textField.

My “clean” solution was to write my own component which simply extends regular Combobox and gives me the textFilterString. It is done, but not checked in into the vaadin directory, i need to recharge my motivation for finishing it :slight_smile:

But i have a “unclean solution for you” with reflections.

I just myde my ovn listDataProvider which extends ListDataProvider

in the constructor of the ListDataProvider i add the comboBox itself.

the important Method to owerWrite is

    public Stream<T> fetch(Query<T, SerializablePredicate<T>> query) {
	  Field currentFilterText = comboBox.getClass().getDeclaredField("currentFilterText");
      String filterText = (String) currentFilterText.get(comboBox);
there i can get the entered Filter Text from the combobox via Reflection.

ofcourse you need try catchs e.t.c.

here is my code, i have things you dont need, so you only need to delete my ByPRedicates