No validation error but still binder.isvalid is not getting executed

Button saveButton = new Button("Save");
        saveButton.addClickListener(buttonClickEvent -> {
            final BinderValidationStatus<Customer> validate = this.binder.validate();
            final BinderValidationStatus<BaseAbstractEntityAddress> validate1 = this.addressForm.getBinder().validate();
            if (this.binder.isValid() && this.addressForm.getBinder().isValid()) {
                Customer customer = new Customer();


                customer = customerService.saveCustomer(customer);
                UIUtils.showNotification(customer.getId() + " created");
            } else {
                UIUtils.showNotification(" No Customer created");

From the above, I do not see any error is thrown from validate method so it should go to the if block but it is not. Not sure what is wrong here though no validation error

Looks the issue is here this.addressForm.getBinder().writeBean(customer.getBaseAbstractEntityAddress());

this is returning null java.lang.NullPointerException: bean cannot be null

BaseAbstractEntityAddress is an abstract class. IDK how to write into an abstract class with binder writeBean

any example ?

You can’t instantiate an abstract class in Java

But if you’re using an abstract type reference, it should work

And the getter should not return null

But for some unknown reason to me, it is failing on this line. If I comment out, it is working

Yes, it seems to me it’s because getBaseAbstractEntityAddress() returns null

correct. since it is an abstract class, I’m not finding any example on how to use writeBean

It doesn’t matter that is in an abstract class

the method returns an object, not a class

and that object is null

you can’t write to a null object


but this is working

yes, because customer is not null

I’m consfused.