roo addon and conversion exception.

Hi All,
this is my first post on the forum, so hi everyone.
Now the problem :slight_smile: :
I’ve made a roo project and defined entity which has field as follow:

@Lob
@Basic(fetch = FetchType.LAZY)
private byte[] description;

roo vaadin plugin has generated the form field for it as the TextField.
Now, when I click the Save button, field is validated and the message “Conversion exception” is show above the mentioned button.

Is there anyone, who knows how to properly define blob text fields? Or sample code, which works?

Second question, is there any documentation about PropertyConverters and Validators? I’ve found a little bit about Validators in the 'Book of Vaadin" but I can’t link the knowledge from the book with the code generated by the roo plugin.

Any help appreciated :slight_smile:

Regards,
Andy.

If the @Lob field is of type String, it should work directly. If you use byte, you need conversions - and things like character encoding would not be obvious anyway.

How these are handled in the Roo generated code depends on whether you chose to use visually composable or automatic forms.

For automatic forms, with the current version, you need to push the getFormFieldFactory() method from the aspect of the form to the form itself, and then modify it to wrap the field e.g. in a FieldWrapper that performs the conversion, perhaps using a separate PropertyConverter.

For visually composable forms, push in the method configureConverters() from the aspect to the form and add the appropriate converter to the map.

Also validators can be set in the form field factory and configureValidators(), respectively. On the other hand, the forms are automatically using JSR-303 bean validation if you have the corresponding annotations in the entities.

The class PropertyConverter comes from the CustomField add-on. Its javadoc could be improved, but what you need to do is implement the format() and parse() methods in your subclass.

Thank you Henri.

Your explanation is very helpful and clear.

In fact, changing the lob type to String solved the problem with conversion. Rest of the suggestions I have to digest and test by myself.