如何在vaadin流中绑定枚举值?

如何在vaadin流中绑定枚举值?,vaadin,vaadin-flow,Vaadin,Vaadin Flow,在使用springboot的vaadin flow项目中,我遇到了一个问题,即带有组合框的枚举值无法绑定。 我在下面提供了我的代码。这里有人能帮我吗 组合框实例化: private ComboBox<Country> nationality = new CompoBox<>("Nationality"); 我想你错过了setItems呼叫。下面是一个基于 package com.vaadin.starter.skeleton; 导入com.vaadin.flow.com

在使用springboot的vaadin flow项目中,我遇到了一个问题,即带有组合框的枚举值无法绑定。 我在下面提供了我的代码。这里有人能帮我吗

组合框实例化:

private ComboBox<Country> nationality = new CompoBox<>("Nationality");

我想你错过了
setItems
呼叫。下面是一个基于

package com.vaadin.starter.skeleton;
导入com.vaadin.flow.component.button.button;
导入com.vaadin.flow.component.combobox.combobox;
导入com.vaadin.flow.component.notification.notification;
导入com.vaadin.flow.component.orderedlayout.VerticalLayout;
导入com.vaadin.flow.data.binder.binder;
导入com.vaadin.flow.router.Route;
导入com.vaadin.flow.server.PWA;
/**
*主视图包含一个按钮和一个单击侦听器。
*/
@路线(“”)
@PWA(name=“Vaadin流程的项目基础”,shortName=“项目基础”)
公共类主视图扩展了垂直布局{
公共主视图(){
组合框组合框=新组合框(“编号”);
comboBox.setItems(ENUM.values());
活页夹=新活页夹();
binder.setBean(newbean());
bind(组合框,Bean::getField,Bean::setField);
按钮按钮=新按钮(“检查值”,
e->Notification.show(“bean中的值是”+binder.getBean().getField());
添加(按钮、组合框);
}
公共枚举{
一,二,树
}
公共静态类Bean{
私有枚举字段;
公共枚举getField(){
返回字段;
}
公共void设置字段(枚举字段){
this.field=字段;
}
}
}
请不要在此处提供代码的图像。将相关部分粘贴到问题中。它有助于更好地回答问题,并使您的问题具有可搜索性。
binder.forField(nationality)
    .bind(Coach::getNationality,Coach:setNationality);