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

时间:2019-03-16 04:36:45

标签: vaadin vaadin-flow

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

组合框实例化

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

绑定代码:

binder.forField(nationality)
    .bind(Coach::getNationality,Coach:setNationality);

1 个答案:

答案 0 :(得分:4)

我认为您错过了<!-- Map --> <div id="map" style="width: 100%; height: 400px;"></div> <input type="hidden" id="location" value="42.6903741,23.3122929" /> <!-- Script --> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=XXX&callback=initMap&language=en" async defer></script> <script type="text/javascript"> function initMap() { // Init location var my_location = $("#location").val().split(","); // Init position var my_position = new google.maps.LatLng(my_location[0], my_location[1]); // Init map var my_map = new google.maps.Map(document.getElementById("map"), { center: my_position, zoom: 17 }); // Init marker var my_marker = new google.maps.Marker({ position: my_position, map: my_map, draggable: true, title: "Choose location..." }); // Init listener google.maps.event.addListener(my_marker, "dragend", function(event) { $("#location").val(event.latLng.lat() + "," + event.latLng.lng()); }); // Init geolocation if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(getLocation); } function getLocation(my_location) { var my_position = new google.maps.LatLng(my_location.coords.latitude, my_location.coords.longitude); my_marker.setPosition(my_position); $("#location").val(my_location.coords.latitude + "," + my_location.coords.longitude); } } </script> 电话。这是一个基于Project Base for Vaadin Flow

的示例
setItems