Combobox. Selected value of the combbox disappears

Hi

I have a combobox which i construct in FormFieldFactory. The values are displayed when i click on the dropdown. If i select any item it shows the selected value. But when i click on any other component in the Form the selected value of the combbox disappears. Here is the code that in my form field factory.

private Field createAndPopulateSelect(final String caption) {
logger.info("[createFieldPopulateSelect]
");
BeanItemContainer container =
new BeanItemContainer(FinCCComponent.class);

	container.addAll(FinCCCodeUtility.FINCCCODES.getComponents().values());
	final ComboBox  select = new ComboBox(caption,container);
	
	select.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY);
	select.setFilteringMode(ComboBox.FILTERINGMODE_STARTSWITH);        
    select.setItemCaptionPropertyId("name");
	return select;
}

Here is the Component code that i want to display in the combo box.

public class FinCCComponent {
private String id;
private String name;
private String desc;
private Map<String,Category> categories = new TreeMap<String,Category>();

public String getId() {
	return id;
}

public void setId(String id) {
	this.id = id;
}

public String getName() {
	return name;
}

public void setName(String name) {
	this.name = name;
}

public String getDesc() {
	return desc;
}

public void setDesc(String desc) {
	this.desc = desc;
}

public Map<String,Category> getCategories() {
	return Collections.unmodifiableMap(categories);
}

public void addCategory(final Category category) {
	categories.put(category.getId(),category);
}

}

HI Any body please help me regarding this. Its been a week posting this query and i am still stuck

I’ve had the same problem, looks like a bug I think. The problem was related to immediateness of the field.
Combo box started to behave well after changing it to non-immediate mode. Good that I don’t need it to be immediate :slight_smile:

If setting a component as non-immediate helps, then there probably still is another bug that just gets triggered later.

I suspect the problem in the (very old) code above might be that the class used as the ID in the container does not have suitable equals() and hashCode() methods. If the instances of the class might change, the combo box will not recognize the new selection as being the same as the old.

If there is another problem and non-immediate fixes it, a short code snippet allowing to reproduce it would help.