entering the text and use the up and down arrows to highlight and enter to select and then use the tab key to leave the field . The value change listener is fired the field selection registered and the value set adn visible in the combo box.
Case 2: Use the mouse.
entering the text and mouse to select and then either use the tab key or the mouse to leave the field . The value change listener is fired the field selection registered and the value set BUT ITS IS deleted from the combo box.
I have tried the combobox wrapped in a form layout and no change.
I have spent all day yesterday trying to fix this problem. This morning I thought go ask those nice Vaadin community people.
And I then try something completely different and I get it to work - doh!
My combobox is using a datasource which extends a BeanItemContainer.
As the user types a name the container lazy loads based on the text and adds lots of beans to the filter.
In the value change listener for the combobox I get the bean from the event and pass it to the container (As described in the linked article).
However in the container I do the following:
In the SuggestionsFIlter:…
public void setSelectedBean(PeopleBean value) {
log.info(“Setting people filter.”);
// removeAllItems();
addBean(value);
p = value;
}
In the container itself:…
private void filterItems(String filterString) {
removeAllItems();
if (p!=null){
addItem(p);
}
if (filterString.length() > 3) {
List people = db.findByName(filterString);
log.info(“Searching for people with name “+filterString+” - “+people.size()+” found.”);
for (GpiPeople p : people) {
addItem(new PeopleBean(p.getPplId(), p.toString(), p));
}
}
}
I do not understand why this works but it does for both keyboard and mouse I am know a happy bunny. If anyone is interested in the full code let me know.