Combobox nullselection dissapears

I’ve got a collection of items (let’s say they’re objects of class A) from database placed into a combobox with a beancontainer, and I’ve set the value of setNullSelectionAllowed() to true. If I don’t do anything else then upon running the application when I click on the dropdown I can see an empty slot.

However if I try to set a nullselection object like this

A item = new A();"Add new item"); comboBox_location.setNullSelectionItemId(item);; The item disappears completely. No item is selected and in the dropdown menu I can’t see the null item, only the items from the bean container.

You need to add the null item to your container too, try something like this:

A item = new A();
comboBox_location.setItemCaption(item, "Add new item");

Thanks for the reply. This now successfully adds the item to the combobox but the select doesn’t seem to work. What I mean is when the view opens nothing is selected even though the select method is called on the null selection, and the null selection item is in the container. If I select something else, and then the null item it suddenly works.


sorry, this was my mistake. You should obviously select null and not the item, since the item is now the nullSelectionItemId. So changing line 5 to;

should do the trick.


Thanks for the quick reply. I’ve already tried that and it did not work.

a) No item is displayed as selected
b) ValueChange event is not triggered


can you post the complete code you’re using? The following simple case works for me and the item with ID 4 is selected when the component is rendered:

ComboBox cb = new ComboBox();
cb.setItemCaption(4, "null item");