简体   繁体   中英

Vaadin add custom validator and content mode

There are some fields to validate. Field's captions contains formatting like " , ", etc with the option captionAsHtml="true". When using someField.addValidator(..., errorString), the error message shows errorString and the field name in brackets(parenthesis) and it looks like that is not cool. Is there any way to show the field name in the validation error message with formatting. Tried to use Notifications instead, but they used in beforeFormSaved and showed when the form is closed unlike using validators.

You did not share your code, but are you trying it this way?

    TextField field = new TextField("<i>Caption</i>");
    field.setCaptionAsHtml(true);
    UserError componentError = new UserError("<b>Error</b>", ContentMode.HTML,
            ErrorLevel.ERROR);
    field.setComponentError(componentError);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM