Binding objects in native select to an object in the form bean

I have a form where in i have a Nativeselect which is populated with Cd Objects.
When the user selects an item from the dropdown i need to populate the FormBean with the selected Cd object.
Please look at my form bean; How will i Map the selected Cd object to the bean.
My vaadin version is 6.8.0.nightly-20111122-c22085.

public class VisitInfo {
	private Cd selectedVisitAction;
	private List<Cd> visitActions = new ArrayList<Cd>();

In FormFieldFactory

if (WebAppConstants.VISIT_ACTIONS.equals(propertyId)) {

			final NativeSelect typeSelect = getNativeSelect("treatmentrealization.form.action");
			final BeanItemContainer<Cd> container = new BeanItemContainer<Cd>(Cd.class , visitInfo.getVisitActions());
			typeSelect.addListener(new Property.ValueChangeListener() {
			return typeSelect;

When the form is submitted i get$ConversionException: java.lang.NoSuchMethodException: java.util.List.(java.lang.String)
at com.vaadin.ui.AbstractField.commit(
at com.vaadin.ui.AbstractField.setWriteThrough(
at com.vaadin.ui.Form.setWriteThrough(
at com.logica.medi.hcmu.webapp.components.form.VisitingDataForm.commit(

I’m sorry I don’t have time to actually try this, but here goes:

First of all the ConversionException gets thrown because the property value type List doesn’t have a constructor from String. Usually property implementations try to fallback for String conversion if there’s a mismatch between property value and type. In this case even that fails.

But the actual problem is that your visitActions is a type of List and the NativeSelect value type (selection) is Cd object. In multiselect mode the value type would be Set. Anyway List is not assignable from Set so visitActions type should be Collection or Set.

Finally however even that doesn’t help because NativeSelect doesn’t support multiselect mode so you should use Select instead of NativeSelect.

BUT long story even longer. I guess you don’t want to have visitActions actually in the form, but create the NativeSelect for property selectedVisitAction and not for visitActions.

Thanks Johannes

creating the Native select for selectedVisitAction worked like Charm. Thanks again