Binder accessible setter error on writeRecord()

Is this a bug or user error?
I thought maybe this was a pre-release issue, but I just upgraded to 24.5.0 and it’s still happening.
The error appear in the logs as soon as I load the page with the form.

2024-10-22T16:20:08.553-05:00  INFO 13423 --- [av-sync] [nio-8080-exec-4] com.vaadin.flow.data.binder.Binder       : name does not have an accessible setter
2024-10-22T16:20:08.591-05:00  INFO 13423 --- [av-sync] [nio-8080-exec-4] com.vaadin.flow.data.binder.Binder       : email does not have an accessible setter
2024-10-22T16:20:08.591-05:00  INFO 13423 --- [av-sync] [nio-8080-exec-4] com.vaadin.flow.data.binder.Binder       : password does not have an accessible setter
public void addBindingAndValidation() {
        BeanValidationBinder<UserDto> binder = new BeanValidationBinder<>(UserDto.class);
        binder.bindInstanceFields(registrationForm); 
        binder.setStatusLabel(registrationForm.getErrorMessageField());

        registrationForm.getSubmitButton().addClickListener(clickEvent -> {
            try {
                UserDto userDto = binder.writeRecord();
                RichResult<Account> result = registerAccount.with(userDto);
                result.handle(
                        // handle result
                );
            } catch (ValidationException exception) {
                // validation errors are already visible for each field, and bean-level errors are shown in the status label.
                registrationForm.getSubmitButton().setEnabled(true);
            }
        });
    }
public record UserDto(
        @NotBlank(message = "Name must not be blank.") String name,
        @NotBlank(message = "Email must not be blank.") @Email(message = "Must use email format.") String email,
        @NotBlank(message = "Password must not be blank.") String password
){}
1 Like

Just a guess: BeanValidations on records were never considered to be allowed when implementing record support.

1 Like

The culprit is the above. When using this version of the constructor, Binder will attempt to find setters and getters by introspection, this naturally cannot work with Records. So we need to add a note about that in the documentation.

1 Like

Correct me if I’m wrong, but the functionality seems not to be broken. There’s just an info message.
If so, we can prevent printing the log message for records.

2 Likes

Fair point! Let’s not log this message for records :+1:
See chore: don't log missing setter message for records by mcollovati · Pull Request #20306 · vaadin/flow · GitHub

1 Like

Yes, it works fine. It just seems to print an unnecessary warning.

Oh, wow, looks like this has been merged already. Do I need to do anything on my end to see the change?

Waiting for the next version ;) It could be included in 24.5.2

1 Like