Lazy, suggesting combobox

Hi,

I’ve got the follwoing problem: I need to display a lot of values from a webservice in a combobox with autosuggestion (stats with is enough, contains would be great). Loading all values in a container and then display them is too slow. The webservice allows batch loading with a filter criterium, an offset an a limit. So there is everything I need.
How to use this in vaadin?

Regards

Daniel

You will need to use a
Filterable Container
as the
ComboBox’s datasource
.

The
Lazy Query Container add-on
might also be of use, but note that it has been written with Table (not ComboBox) in mind.

Has anyone gotten the LazyQueryContainer to work with the ComboBox successfully with filtering (i.e. typeahead feature of ComboBox)? I’ve got the LQC working fine with tables including filtering but not the combobox :frowning:

I am able to get the JPAContainer to work but the performance is not that good because it issues a separate query for each option when constructing the view. Ideally there should be one count query and one query to fetch the results at a time.

Also is there a way to add a delay before issuing a server side call? For example, for a fast typist you would want to avoid doing a lookup until they finish typing a word instead of issuing a request on each key press. For example if I quickly type ‘f’ ‘o’ ‘o’ I would want to apply ‘foo’ as a filter and return the results rather than doing an expensive DB lookup on each letter: ‘f’, ‘o’, ‘o’ .

To clarify for the original poster. In my case I am using the DB to populate the LQC via a service API so it doesn’t depend on JPA nor JDBC like the JPAContainer and SQLContainer. Using the LQC is completely applicable to a web service as well.

It really boils down to creating your own QueryFactory and Query (I extend AbstractBeanQuery) implementations to provide the beans no matter what the ultimate source is.

The first problem you will run into is that the LQC does not implement Filterable so you will need to extend it which isn’t too difficult. There’s a couple of good references that I mentioned here:


https://vaadin.com/forum/-/message_boards/view_message/1553308

I was able to get it working just fine with Tables but Select components seem to call different methods (by index I think) and it breaks down due to ordering issue I believe.

See getOptionsWithFilter() in Select where it dynamically adds a Filter. The filter gets removed before the actual items are queried via AbstractBeanQuery.loadBeans() which throws off the filtered count and items displayed.

Container.Filterable is not really enough. You also need to implement
Container.Indexed
(or there will be many round trip messages still sent). This was the key for me to get the ComboBox working with Lazy Query Container.