com.vaadin.flow.data.binder.
Class DefaultBinderValidationErrorHandler
All Implemented Interfaces:
Default implementation of BinderValidationErrorHandler.
This handler applies visual effects for the field if its type allows this:
- If the field's class implements
HasValidationinterface then its validity and error message is set based on aValidationResult - If the field's class may have a theme (e.g. implements
HasThemeorHasElement) then theme name derived from theErrorLevelof theValidationResultinstance is applied. E.g., forErrorLevel.WARNINGthe element will get the "theme"="warning" attribute and value in HTML.
Since:
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearError(HasValue<?, ?> field) Clears the error condition of the given field, if any.
protected voidclearErrorTheme(HasValue<?, ?> field) Clears error theme for the
field.protected StringgetErrorThemeName(ErrorLevel errorLevel) Gets the theme name for the
ErrorLevel.Gets themes for the
field.voidhandleError(HasValue<?, ?> field, ValidationResult result) Handles a validation error emitted when trying to write the value of the given field.
protected voidsetErrorTheme(HasValue<?, ?> field, ValidationResult result) Sets error theme for the
fieldbased onresult.
-
Constructor Details
-
DefaultBinderValidationErrorHandler
public DefaultBinderValidationErrorHandler()
-
-
Method Details
-
handleError
Handles a validation error emitted when trying to write the value of the given field.
Specified by:
handleErrorin interfaceBinderValidationErrorHandlerParameters:
field- the field with the invalid valueresult- the validation error resultSee Also:
-
clearError
Clears the error condition of the given field, if any.
Specified by:
clearErrorin interfaceBinderValidationErrorHandlerParameters:
field- the field with an invalid valueSee Also:
-
getErrorThemeName
Gets the theme name for the
ErrorLevel.Parameters:
errorLevel- the error levelReturns:
a theme name for the error level
-
getThemes
Gets themes for the
field.Parameters:
field- a fieldReturns:
an optional theme list, or an empty optional if the
fielddoesn't have it -
clearErrorTheme
Clears error theme for the
field.Parameters:
field- a feild -
setErrorTheme
Sets error theme for the
fieldbased onresult.Parameters:
field- a fieldresult- a validation result
-