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:

    [code]

NativeSelect select = new NativeSelect();
select .setNullSelectionAllowed(false);
select .setImmediate(true);
for(int i=0; i<10; i++){
cbTDocumento.addItem(“item”+i);
}
[/code]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.