2015-01-05 38 views
0

Im相當新的它Vaadin,我不能做簡單的結合(我很多谷歌)Vaadin場羣結合枚舉與文本字段或等

我有個人類例如性別一些領域。 性別 - 其典型的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. 

能否請您分享您的想法如何解決它。

+0

'DateField'?你是不是指'TextField'? – cfrick

回答

3

你就必須創建自己的Converter<String,Gender>並將其分配給您的TextField

+0

非常感謝! –

+0

良好的鏈接:https://vaadin.com/wiki/-/wiki/Main/Creating%20your%20own%20converter%20for%20String%20-%20MyType%20conversion –