I am currently using a ComboBox as a drop down of objects that have been loaded using:
BeanItemContainer<Organization> orgBeans = initOrgBeans();
final ComboBox orgNames = new ComboBox("Organizations", orgBeans);
orgNames.setItemCaptionPropertyId("name");
orgNames.setImmediate(true);
orgNames.setNewItemsAllowed(true);
orgNames.setTextInputAllowed(true);
I only want to see the name value for each object but still have each object contained in the ComboBox. I use other fields within the objects to populate other components when it is selected in the ComboBox. The value change listener works great with this…however, when I change the name field in the ComboBox I cannot get the value change listener to pick it up. Once I leave the focus of the ComboBox the text is returned to its original state.
I want to be able to change the name field in the ComboBox and also be able add new names and create a new objects with them and add it to the ComboBox. If I cant get this to work I see two easy options…
- add another text field for names to be edited and created in or
- change the ComboBox to strings and load just the names of the objects into it and do string comparisons to find the object
#2 breaks down when I have to attach this to the server and the PK is based on a guid
if you need it here is my current value change event:
orgNames.addValueChangeListener(new ComboBox.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
(my code is here)
}
});