I am trying to understand if this is a bug or I should just change my implementation to handle this better.
- I type ‘so’ into combobox
- I select the option “Some words”
- setValue fires with value “a_b” (desired)
- I select the text field so that combobox loses focus
- setValue fires again with value “Some words” and ultimately the value of the field is the caption and not the item (not desired)
So basically setNewItemsAllowed(true) disables the possibility to use the search function within the combobox.
Vaadin version used 7.7.6
@Override
protected void init(VaadinRequest vaadinRequest) {
ComboBox cb = new Box();
cb.setNewItemsAllowed(true);
String s1 = "a_b";
String s2 = "Some words";
cb.addItem(s1);
cb.setItemCaption(s1, s2);
setContent(new VerticalLayout(cb, new TextField()));
}
// this is just here to add breakpoints for debugging easily
public static class Box extends ComboBox {
@Override
public void setValue(Object newValue) throws ReadOnlyException {
super.setValue(newValue);
}
@Override
protected void setValue(Object newFieldValue, boolean repaintIsNotNeeded, boolean ignoreReadOnly) throws ReadOnlyException, ConversionException, InvalidValueException {
super.setValue(newFieldValue, repaintIsNotNeeded, ignoreReadOnly);
}
}