Vaadin字段组将Enum与TextField等绑定

时间:2015-01-05 21:52:46

标签: java binding enums vaadin vaadin7

我很新,它是Vaadin,我不能做简单的绑定(我很有道理)

我有Person类,其中包含一些字段,例如Gender。 性别 - 它的典型java枚举。

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

他们我收到了一个例外:

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.

请与您分享如何解决问题的想法。

1 个答案:

答案 0 :(得分:3)

您必须创建自己的Converter<String,Gender>并将其分配给TextField