NativeSelect in Vaadin 8

Hi!

NativeSelect has changed very much in Vaadin 8. I would like to ask you how to enter data such like in Vaadin 7 that there is an index and there is a text. Does text appear and getValue () returns the index?

nSelect.addItem(1);
nSelect.setItemCaption(1, "First");
nSelect.addItem(2);
nSelect.setItemCaption(2, "Second"));

If I selected “Second” the getValue() = 2

How it is work in Vaadin 8? In each example, only String is listed.

Thanks!
Tamás

You can try itemCaptionGenerator;


			nsSelect.setItemCaptionGenerator(item -> {
				String caption="";
				if(item.equals("1")){
					caption="First";
				}else if(item.equals("2")){
					caption="Second";
				}
				
				return caption;
			});