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:
- Click button “LA” => LA will be shown in Combobox.
- Click button “FOREIGN” => FOREIGN will be shown.
- Click button “LA” again => FOREIGN is still shown (but valueChangedListener souts “LA”, which is correct)
- (optional) Click button “MUC” => MUC will be shown.
- Now the same game with “MUC” and “FOREIGN”.
Did I any mistake or is this a problem of the combobox?
Greets
Andi