简体   繁体   English

Vaadin字段组将Enum与TextField等绑定

[英]Vaadin field group bind Enum with TextField or etc

Im pretty new it Vaadin and I cannot make simple binding (i google alot) 我是Vaadin的新手,我无法进行简单的绑定(i Google很多)

I have Person class with some field for example Gender. 我有某些领域的Person类,例如Gender。 Gender - its typical java enum. 性别-典型的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)

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. 能否请您分享一下解决方法。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM