Issues related to Binder with Custom Component

I’ve created a component that extends AbstractField. When implementing the Component I followed the instructions as mentioned on the vaadin documentation and also made use of the vaadin addon template available at github. I integrated my custom component into a web application on a View with multiple other standard Vaadin components. The View class contains a Binder field for a JPA Entity. The binding is done via binder.bindInstanceFields(this); When click the save Button I obtain the bean via binder.getBean() and call a backend Service to persist the entity. Doing this I observe the following error message “ConstraintViolationImpl{interpolatedMessage=‘darf nicht leer sein’”. My Bean class contains javax.validation Annotations specifically for the field “beschreibung” which should not be empty (@NotEmpty). So I assume that the value of my component is not propagated back to the model. Can someone help me with this?

The code of my custom component is publicly available at: https://github.com/jhoffmann99/vaadin-trix-editor. Thx in advance :slightly_smiling_face:

The above link seems not to work. I get a “Page not found”

Just to confirm: are you using a BeanValidationBinder, right?

I’m sorry. The repo was private. Now it’s public :slightly_smiling_face:

Im using the class com.vaadin.flow.data.binder.Binder

The binder worked fine with a previous version of the class where I used a TextArea (Vaadin) for “beschreibung” field.

Even if I replace this private Binder<Gewaesser> binder = new Binder<>(Gewaesser.class); with that private Binder<Gewaesser> binder = new BeanValidationBinder<>(Gewaesser.class); the resulting error message is the same.

The component’s actual value never updates, the issue is before the Binder.

I made a PR for you that modifies the test view so that it can be tried out.

Didn’t yet look into what is the actual issue/fix.

Ok, can you have a look at the main Class? I’ve also tried to implement the HasValue Interface … without success

Initial value don’t seem to get in either :thinking:

The component looks cool, there can never be enough rich text editors :slightly_smiling_face:

I need to check the trix docs a bit how it is supposed to be used.

Thank you. However, the main credit goes to the makers of Trix editor :wink:

Ok :slightly_smiling_face:

Had to struggle with something else (new Vaadin Add-on Directory) for a while, but gave you another PR for the component. As trix was not firing value change events on the hidden input, nothing was synchronised. Now it uses its JS api instead. I didn’t check, but I’d expect it to work with Binder now as well.

I hope you will be able to share the component in the Directory as well, would be cool to get that listed. I’m sure some would prefer that over the default RichTextEditor or my TinyMCE wrapper.

Thanks Matti for further investigation and the PR. I will check that out tomorrow. I will also publish the component in the directory soon.

@quintessential-ibex Hi Matti I just wanted to tell you that I’ve published the Trix Editor Addon at Vaadin directory. Here’s the link: https://vaadin.com/directory/component/trix-editor :smiley: