Vaadin 8 How can I do validation like Vaadin 7 valerrdisp-vaadin-addon

Hi,

I want to validate form by displaying error messages right to text field how is this possible in vaadin 8 ?

The simplest way is to use
withStatusLabel
method in binder. Just add Label component in your UI and place it on right side of the TextField in your layout, e.g. both in horizontal layout, and use horizontalLayout.addComponets(textField, label). The give in your binding the label component as parameter withStatusLabel(label). Then Binder will automatically use the given label to show the error messages.

Hi thanks

Its worked for me but,

I am using FormLayout how can I add statusLabel in form layout ?

Since you want the labels to be on right side of the fields aligned with the fields, the FormLayout is not the correct approach. I would use either VerticalLayout containin form rows as HorizontalLayouts and using alignments to make it look nice, or alternatively GridLayout. It really depends on what you are trying to achieve.

Hi thanks for quick response.

ok, if I dont want to use label to show error message,

Can you please tell me how can I show pop up message of error message of binder(message which we are giving for label of withStatusLabel).


withValidationStatusHandler(…)
For that you need to do some more work, but it is quite straightforward by method of the Binder and writing custom
BindingValidationStatusHandler
, where you need to implement statusChange method.