Displaying selected value in NativeSelect

If I wanted to convert one of the fields in the AddressBook application into a NativeSelect, how would I display the “selected” value in the editor when user clicks in the table. For example, say field “Company” is to be the NativeSelect, and the allowable values are “Vaadin”, “Apache”, “Apple”.

I can change the field type in the initEditor method as follows (companyList would be populated in createDummyDatasource):

if (fieldName.equalsIgnoreCase(COMPANY))
			{
				NativeSelect field = new NativeSelect();
				editorLayout.addComponent(field);
				field.setWidth("100%");
				field.setCaption(COMPANY);
				field.setContainerDataSource(companyList);
				field.setItemCaptionPropertyId("company_name");
				editorFields.bind(field, fieldName);
			}

However, when the user clicks in the table, how do I populate the selected company in the editor? I’ve tried all kinds of code but it does not work

In the initContactList method, I’ve tried changing the code for the addValueChangeListener method as follows:

				Object contactId = contactList.getValue();

				if (contactId != null)
					editorFields.setItemDataSource(contactList
							.getItem(contactId ));
				
				
				NativeSelect f = (NativeSelect) editorFields.getField(COMPANY);
				f.select(contactList.getItem(contactId ).getItemProperty(COMPANY).getValue());
				editorLayout.setVisible(id != null);

I also tried f.setValue() in the code above with no luck!

Thanks for looking into this!

Alex