Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Why I can't set a converter to a ComboBox?

Vesa Tamminen
6 years ago Jun 11, 2015 11:41am
Sergey Budkin
6 years ago Jun 11, 2015 12:09pm

Hi Vesa,
from pure coding point of view, you should convert from Object instead of Boolean, because ComboBox extends AbstractField<Object>. But what's the purpose of converter in this case? Consider using item captions instead (chapter 5.5 3): https://vaadin.com/book/vaadin7/-/page/components.selection.html

With best regards,
Sergey.

Vesa Tamminen
6 years ago Jun 11, 2015 1:55pm
Sergey Budkin
6 years ago Jun 11, 2015 2:21pm

You can't pass null as item, but you can do like this:

final Object nullItem = "null-item";
ComboBox comboBox = new ComboBox();
comboBox.addItem(new Date());
comboBox.addItem(nullItem);
comboBox.setNullSelectionItemId(nullItem);
comboBox.setItemCaption(nullItem, "Null value caption");

Best regards,
Sergey.

Vesa Tamminen
6 years ago Jun 15, 2015 6:21am
Sergey Budkin
6 years ago Jun 15, 2015 10:43am