ComboBox with NewItemHandler, selecting new value

I have a
ComboBox
, backed by a
BeanContainer
, populated from a
List
.
NewItemsAllowed
is true and I add a
NewItemHandler
which adds a new item to the
BeanContainer
and calls select() to select the new item.


final ComboBox motifSubjectSelect = createSelect();
...
motifSubjectSelect.setNewItemHandler(new NewItemHandler() {
	private static final long serialVersionUID = 1L;

	@Override
	public void addNewItem(String newItemCaption) {
		Classification newSubject = 
			new Classification(newItemCaption, ClassificationSpecification.MOTIF_WORD);
		newSubject.setTitle(newItemCaption);
		dataContainer.addBean(newSubject);
		motifSubjectSelect.select(newSubject.getId());
	}
});
 

This works insofar that the NewItemHandler is called, the BeanContainer’s BeanIdResolver (which I have provided) works fine and the setter for the relevant property of the form is called, all with correct values. But, the ComboBox is cleared when it loses focus. Calling


motifSubjectSelect.requestRepaint();
 

does not help. What am I doing wrong here? What do I need to to do to get the new value to “stick”?

Sigh, I thought it was the Vaadinic way to use a Container with the ComboBox. When I went back to the more primitive way, adding each item with


for(Classification motifSubject : motifSubjects) {
	motifSubjectSelect.addItem(motifSubject);
	motifSubjectSelect.setItemCaption(motifSubject, motifSubject.getIngressTitle());
}
motifSubjectSelect.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_EXPLICIT);

...

	@Override
	public void addNewItem(String newItemCaption) {
		Classification newSubject = 
			new Classification(newItemCaption, ClassificationSpecification.MOTIF_WORD);
		newSubject.setTitle(newItemCaption);
		motifSubjectSelect.addItem(newSubject);
		motifSubjectSelect.setItemCaption(newSubject, newItemCaption);
		motifSubjectSelect.select(newSubject);
	}

 

everything worked fine.