Possible Bug in Combobox? (departed value)

Hello.
I hope I didn’t overlook a similar topic in the forum.

My problem is, that the combobox doesn’t refresh to the right value in some special condition.
This condition is on hand, when a value will be set, that isn’t part of the items in der content container.
If I combobox.setvalue(“foreignItem”); the combobox will show “foreignItem”, but when I choose the Item, that was active before and is part of the items in content container, “foreignItem” will stay as value in the combobox (but the valueChangeListener has already the right value in its event).

My Code (partly):

public VaadinComboBoxTest(TestUI pUI)
{
VerticalLayout layout = new VerticalLayout();
property = new ObjectProperty<>(“”);

BeanItemContainer contentContainer = new BeanItemContainer<>(String.class);
comboBox.setPropertyDataSource(property);
comboBox.setContainerDataSource(contentContainer);

contentContainer.addAll(Arrays.asList(“LA”, “MUC”, “HH”));
property.setValue(“MUC”);

Button buttonLA = new Button();
buttonLA.setCaption(“LA”);
buttonLA.addClickListener((Button.ClickListener) event → {
property.setValue(“LA”);
});
layout.addComponent(buttonLA);

Button buttonMUC = new Button();
buttonMUC.setCaption(“MUC”);
buttonMUC.addClickListener((Button.ClickListener) event → {
property.setValue(“MUC”);
});
layout.addComponent(buttonMUC);

Button buttonF = new Button();
buttonF.setCaption(“FOREIGN”);
buttonF.addClickListener((Button.ClickListener) event → {
property.setValue(“FOREIGN”);
});
layout.addComponent(buttonF);

layout.addComponent(comboBox);

pUI.setContent(layout);
}

Approach:

  1. Click button “LA” => LA will be shown in Combobox.
  2. Click button “FOREIGN” => FOREIGN will be shown.
  3. Click button “LA” again => FOREIGN is still shown (but valueChangedListener souts “LA”, which is correct)
  4. (optional) Click button “MUC” => MUC will be shown.
  5. Now the same game with “MUC” and “FOREIGN”.

Did I any mistake or is this a problem of the combobox?

Greets
Andi

Hi,

I am trying to follow your logic. I think you should have comboBox.setNewItemsAllowed(true); to get it work.

Br. Tatu

Yeah, the most offbeat thing in our features here is, that we often set the value programmatically and not manually by user. That may confuse you here.
P.S. comboBox.setNewItemsAllowed(true); didn’t changed anything in this regard.
Thank you anyway!