set null value caption for combobox in vaadin 7

Hi there,
I am using containerDataSource to set the values for selection. In addition I allow null - thus I get blank item in the combobox selection.

My ComboBox instantiation looks like this

ComboBox comboBox = new ComboBox();
comboBox.setTextInputAllowed(true);
comboBox.setNullSelectionAllowed(true);
BeanContainer dataSource = configureCommonDataSource(objectType); // BeanContainer<String, CustomObject>
// bean id resolver is set to CustomObject.getName()
comboBox.setContainerDataSource(dataSource);

But how to provide the null selection as - instead of blank line?

Check ComboBox.setNullSelectionItemId(…), it sets the item that is used when null selected. So add item with caption “-” to container and set it with this method.

https://vaadin.com/api/framework/7.7.14/com/vaadin/ui/AbstractSelect.html#setNullSelectionItemId-java.lang.Object-

Tatu Lund:
Check ComboBox.setNullSelectionItemId(…), it sets the item that is used when null selected. So add item with caption “-” to container and set it with this method.

https://vaadin.com/api/framework/7.7.14/com/vaadin/ui/AbstractSelect.html#setNullSelectionItemId-java.lang.Object-

Won’t this method require to add element to that container that would represent -? Like CustomObject that keeps - value.

Won’t this method require to add element to that container that would represent -?

Yes, if you mean the data source Container of the ComboBox