FieldWrapper and error indicator

Dear all,

I’m just playing around with FIeldWrapper. I try the following:

Form → MyComponent(extends FieldWrapper) → CompositionRoot (CSSLayout or HLayout) → Textfield (and later other info-components, but for test just a simple textfield)
Wrapped component is the textfield

Now the required indicator works fine and is rendered next to the caption, well the caption works fine too. It is rendered as part of the form.
But the error indicator seems to work differently… How can I get it working like the required indicator? I noticed CSSLayout has some special handling for errors and renders them itself, similar to the Form. So I switched to HLayout. But then the error is not rendered at all.

Any ideas or am I doing something wrong?
I dived into the Vaadin code, but I didn’t figure out how the error indicator works in detail. Is there anyone who can explain that? :slight_smile:
I see the ValidationException has “UIDL-code” that tells the client there is errors to render. The error is rendered in VCaption (client). But the mechanism is not fully clear to me yet.

Thank you

Each component has a caption which consists (on the client side) of an icon, a caption text and an error indicator. Most components let the containing layout render the caption, whereas a few (like Button or CheckBox) render their captions themselves. The server sends information about the need for an error indicator to the client based on validation and whether setComponentError has been used etc.

While I cannot answer the question directly (would need to dig into it), for FieldWrapper you should take a look at the javadoc and implementations of FieldWrapper.getErrorMessage(), FieldWrapper.getValidationError() and FieldWrapper.paintContent(). It also matters whether you have a validator on the contained field or on FieldWrapper itself - the error indicator would probably be painted in the captions of different components in each case.