Clearing combobox selection after selecting?

I’m using a ComboBox with filtering together with LazyQueryContainer to serve as a suggestion box.

Currently, someone types in a partial text string, and then selects one of the matching items.

Upon selection, another part of my application opens a tab.

At this point, I’d like the combo box to “clear”.

I have attempted to set its value to null at the end of the listener that reacts to the selection. This does not appear to have any effect, as the item that caused the tab to open is still selected in the combo box.

I am thinking that perhaps I could use a blur listener, but this isn’t quite what I want as I’d like the person’s text to remain in the box if he
doesn’t
select an item.

Does anyone have any suggestions?

Thank you,
Laird

Has anybody been able to work this out?

Setting the value to null should work. Just make sure to set the box as immediate and notice that the value change event is called also when the value is set to null. See
an example
.

I assume that the use of LazyQueryContainer is not relevant with this.

There is some very odd behavior going on with the combobox input text after you’ve selected one value. Select one value and then try clicking the dropdown arrow a couple of times, and you should see the previously selected value popping up (i.e. not null value). IMO a very ugly bug that I’d like to see fixed.

Sounds like a bug. Please try the latest nightly as a bug very similar to this has been fixed recently (http://dev.vaadin.com/ticket/5556). If it does not work you should create a ticket (http://dev.vaadin.com/newticket) and attach a test case so we can fix it.

Just wanted to add a note to this thread that I was able to clear out the previous selection of a ComboBox by calling setInputPrompt(“”). This is as of 6.5.1.

I found this very example is not working with new items. Is this a bug?

combobox.setNewItemsAllowed(true)

I recognized this using the TokenField AddOn. As in its demo this is working, the bug might be new… see: http://marc.virtuallypreinstalled.com/TokenField/

I opened a bug: http://dev.vaadin.com/ticket/13413

So now 10 years into the future. comboBox.setValue(null) (v14) results in a NullPointerException.

Is there a better way?