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.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
nativeSelect
Hello,
Im very new using vaadin, and im very excit to use, but i have an issue with nativeSelects.
Coming from html the SELECT there are 2 values, "value" and "description", becouse i want to show a distinct value than the value that i work (codes normaly)
then, in my code:
NativeSelect select = new NativeSelect();
select .setNullSelectionAllowed(false);
select .setImmediate(true);
for(int i=0; i<10; i++){
cbTDocumento.addItem("item"+i);
}
i get value with:
select.getValue();
ok, ¿how can set the internal value for work with codes?
Thx!
Hi,
I'm not sure I got your question right, but if cbTDocumento == select, you can individually set the caption for each item as follows:
for (int i=0; i<10; i++) {
String itemId = "item" + i;
select.addItem(itemId);
select.setItemCaption(itemId, "Caption for item" + i);
}
The UI will show "Caption for item0", "Caption for item1", etc. and the getValue() method will return something like "item0", "item1", etc.
You may also want to take a look at the setItemCaptionPropertyId method.