Select component that is bound to a bean does not have any options?

I have created a Select component which uses a list of enum values. This is on an editor layout.

The functionality, is that a user can change the status of a course in a select box (“Created”, “Paused”, “Draft”, “Cancelled”)

The select component is bound to a bean of CourseDTO.

When I select a value it shows the correct value that is in the courseStatus property of the bean, however there are no other options for me to select.

Does the binder clear the select options, or is there something I am missing?

As you can see here, I have set the values for the select in the constructor.

    private Select<CourseStatus> courseStatus = new Select<>();
    private final BeanValidationBinder<CourseDTO> binder;
    private CourseDTO selectedCourse;

   public void MyView() {
       binder = new BeanValidationBinder<>(CourseDTO.class);
       binder.bindInstanceFields(this);
       binder.forField(courseStatus).bind("courseStatus");
       courseStatus.setItems(CourseStatus.values());
   }
   
   private void populateEditorLayout(CourseDTO course) {
        this.selectedCourse = course;
        binder.readBean(this.selectedCourse);
    }

Also when no bean is selected the select box is completely empty.
Not sure what I need to do here to fix this

Hi, I tried the snippet and it works fine for me (I see all the enum options listed in the select):

@Route("selectpage")
public class SelectPage extends Div {
    
    private Select<CourseStatus> courseStatus = new Select<>();
    private final Binder<CourseDTO> binder;
    private CourseDTO selectedCourse;

   public SelectPage() {
       super();
       binder = new Binder<>(CourseDTO.class);
       binder.bindInstanceFields(this);
       binder.forField(courseStatus).bind("courseStatus");
       courseStatus.setItems(CourseStatus.values());
       add(courseStatus);

       CourseDTO course = new CourseDTO();
       course.setCourseStatus(CourseStatus.PAUSED);
       populateEditorLayout(course);
   }
   
   private void populateEditorLayout(CourseDTO course) {
        this.selectedCourse = course;
        binder.readBean(this.selectedCourse);
    }

    public class CourseDTO {
        private CourseStatus courseStatus;

        public CourseStatus getCourseStatus() {
            return courseStatus;
        }

        public void setCourseStatus(CourseStatus courseStatus) {
            this.courseStatus = courseStatus;
        }
    }

    public enum CourseStatus {
        CREATED, PAUSED, DRAFT, CANCELLED
    }
}

Hmmm I wonder if its because my bean is immutable and the binder doesn’t like that

Ah - the logs say this

2022-11-11 08:58:00,059 INFO com.vaadin.flow.data.binder.Binder bind [courseStatus does not have an accessible setter]