1

I am using Vaadin 7.5.5 and Viritin 1.35. I have implemented a LazyComboBox that is backed by a Spring Data JPA service call and repository.

My basic setup for the LazyComboBox is:

    initList(
            Site.class,
            new FilterablePagingProvider() {
                @Override
                public List findEntities(int index, String name) {
                    return sitesService.findByName(name);
                }
            },
            new FilterableCountProvider() {
                @Override
                public int size(String name) {
                    return sitesService.countByName(name);
                }
            },
            PAGE_SIZE
    );

This works great when I am typing in the combo box.
If I pick an item from the first page (page 0) I can then leave the combo box, come back to it, and click the drop down arrow again and the previously selected item is still selected.

However, if I choose an item from any page other than 0, then clicking the drop down arrow causes the selected item to become null and the user has to find the original item again.

I can post the details of the service and repository if needed but it isn't anything more complicated than a select * from table where name like '%' + name + '%'.

How do I keep the selected value in the combo box no matter what page was chosen?

Thank you.

cbmeeks
  • 11,248
  • 22
  • 85
  • 136

1 Answers1

0

I think you should call setNullSelectionAllowed(false); on this combo box.

Also, a solution to keep selected value after navigation can be to store it in a session value, then you'll be able to retreive it wherever you are. See Session wiki page

Supamiu
  • 8,501
  • 7
  • 42
  • 76