There are a way to show a error message and paint the field in RED without make a bind?
I have one Combobox to select, and a button to click. so If my user click the button without select anything in combo, I wanna to show that error message in combobox,(No need to create a bean just to bind a field)
Maybe it’s enough to start from the vaadin-text-field and get the label part.
But I don’t know how to get shadow DOM parts from Java API.
The cb.getElement().getShadowRoot() -> throw new NoSuchElementException("No value present")
Maybe some CSS selector on the vaadin-text-field:
:host(.warning) [part="error-message"]
{
/* maybe some content */
}
or some voodoo magic JS can do the trick, I dunno.
If it’s appropriate to you to show the error message in another label (maybe you can composite the label and combobox in a FlexLayout or in a CustomField) then that is easier. Just put the combobox and the label in the flexLayout (flexDirection:column) and show the label (set visible or just set the text/value) when the combobox is empty.
ComboBox and many other components implement HasValidation. As such, they have setInvalid(...) and setErrorMessage(..). No need for any workarounds. Or am I missing something here?
Patrick Schmidt: ComboBox and many other components implement HasValidation. As such, they have setInvalid(...) and setErrorMessage(..). No need for any workarounds. Or am I missing something here?