Vaadin8 comboBox: how to manage code and a description list

I have a bean

class MyBean {
Integer code;
String name
Integer typeCode;

MyBean myBean ;

and a list with types descriptions

class TypeDescription {
Integer typeCode;
String typeDescription;

List listrOfTypesDescriptions

  • in the form, the comboBox must show list of types (listrOfTypesDescriptions)
  • and the type selected must be stored in the field typeCode of my object (Integer myBean.typeCode )

I defines ComboBox Type : TypeDescription

protected ComboBox cbxType;

and assign to ComboBox a list of TypeDescription


how I bind ComboBox to bean attribute typeCode?

  • ComboBox Type is TypeDescription
  • typeCode type is Integer

binding generate error

Binder binder = new Binder<>(MyBean .class);

.bind( MyBean ::getType, MyBean ::setType));

becouse ComboBox Type is TypeDescription

thanks for any help


A couple of thoughts:

  • You can use
    to define an int (typecode) ↔ TypeDescription Converter
  • You don’t
    to use method references like MyBean::getType and ::setType in
    , you can also create the getter and setter manually, for example with lambda expressions