Java Dude
Java Dude

Reputation: 596

Vaadin field group bind Enum with TextField or etc

Im pretty new it Vaadin and I cannot make simple binding (i google alot)

I have Person class with some field for example Gender. Gender - its typical java enum.

    fieldGroup.setItemDataSource ( new BeanItem<> ( person ) );
    fieldGroup.setReadOnly ( true );
    ....
    DateField field = new DateField ( "some_caption");
    fieldGroup.bind ( field, "geenger"); //property - "gender" field (type - enum Gender)

them Im receiving an exception:

Caused by: com.vaadin.data.util.converter.Converter$ConversionException: Unable to convert value of type model.Gender to presentation type class java.lang.String. No converter is set and the types are not compatible.

Can you please share your ideas how to fix it.

Upvotes: 0

Views: 1036

Answers (1)

cfrick
cfrick

Reputation: 37033

you would have to create your own Converter<String,Gender> and assign it to your TextField

Upvotes: 3

Related Questions