ComboBox setItem from Object return only the end of data (Vaadin 24.1)

Hi, i want to create ComboBox that contain ‘code’ from Department Database,

this is the preload code for combobox

    private void populateDepartment(){

        try {
            listDepartment = departmentService.getDepartmentListForComboBox(false);


            for (Department department : listDepartment) {

            if (listDepartment.size() > 0)
        }catch(Exception ex) {

i test it with print size() of the listDepartment and it return the correct value, but the ComboBox is only show the last one of the database data, (‘ALL’ at the combobox can be set from the set value. see the image at the attachment)

thank you!

EDIT : i tried this method at Vaadin 8 and i dont have this issue at all

and this is data from Department table

setItems is not additiv, it replaces the current list and therefore only the last item(s) is/are present

is there any way to add all department without replace it?

setItems(listDepartment) is normally the way to go instead of iterating over it

i tried it but it returns the unique id instead of ‘code’ table

if i inisialize the listDepartment with get, i need to set int for which data it’s all described here with custom representations

If you really really only need the strings. Just do a>d.code).to list (pseudo code) and add this instead of the department list

ahh, i get it, its kinda different with Vaadin 8, i need to filter data first before importing the result to the combobox, thank you!