ComboBox binding (Vaadin 12+)

I have a Client entity as follows:

package com.kargil.mybatis.bean;

public class Client {
    private String clientKey;
    private String name;
    private String contactPerson;

    public Client() {
    }

    public Client(String clientKey, String name, String contactPerson) {
        this.clientKey = clientKey;
        this.name = name;
        this.contactPerson = contactPerson;
    }

    
    public String getClientKey() {
        return clientKey;
    }

    public void setClientKey(String clientKey) {
        this.clientKey = clientKey;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    
    public String getContactPerson() {
        return contactPerson;
    }

    public void setContactPerson(String contactPerson) {
        this.contactPerson = contactPerson;
    }
}

How do I define comboBox binding ?

I have the following code so far but cannot figure out the binding statement that will bind the component to the Binder object :

List<Client> clientList = ClientManager.selectClients();
ComboBox<Client> clientCB = new ComboBox<>("Client");
clientCB.setItems(clientList);
clientCB.setItemLabelGenerator(Client::getName);
	
FormLayout form = new FormLayout(
	clientCB
);
		
Binder<ClientPayment> binder = new Binder<>(ClientPayment.class);
binder.bind(clientCB, .........
	

So I need to know what to code in order to bind the component to the “binder” instance.
I want the comboBox to display field “name” but want field value “clientKey” to be stored value during binding.

Thanks in advance for your help

Just a note. If you have a ComboBox<Client> the value will be of type Client, not String, which is the type of client key you have. So if you want to bind this ComboBox to a property of String type, you need to have also a Converter (which you set with withConverter(..) method of Binder), that Converts between Client presentation type and String model type. This is in your case naturally straightforward, since your Converter can simply use Client::getClientKey() for Client to String conversion. I hope this will help you to find the solution.

Thank you Tatu. I am however still struggling with the actual code I will use with my binder.bind(clientCB, … statement. I have not found good sample code anyway.
What code do I use in my “.withConverter” and my “.bind” statements .

Please help.
THanks

As registered Vaadin developer you should be able to access this video training which presents Binder in detail, it has some examples you are looking for

https://vaadin.com/training/course/view/v10-forms