com.vaadin.flow.data.binder.
Class DefaultBinderValidationErrorHandler
- java.lang.Object
-
- com.vaadin.flow.data.binder.DefaultBinderValidationErrorHandler
-
All Implemented Interfaces:
public class DefaultBinderValidationErrorHandler extends Object implements BinderValidationErrorHandler
Default implementation of
BinderValidationErrorHandler
.This handler applies visual effects for the field if its type allows this:
- If the field's class implements
HasValidation
interface then its validity and error message is set based on aValidationResult
- If the field's class may have a theme (e.g. implements
HasTheme
orHasElement
) then theme name derived from theErrorLevel
of theValidationResult
instance is applied. E.g., forErrorLevel.WARNING
the element will get the "theme"="warning" attribute and value in HTML.
Since:
Author:
Vaadin Ltd
See Also:
- If the field's class implements
-
-
Constructor Summary
Constructors Constructor Description DefaultBinderValidationErrorHandler()
-
Method Summary
All Methods Modifier and Type Method Description void
clearError(HasValue<?,?> field)
Clears the error condition of the given field, if any.
protected void
clearErrorTheme(HasValue<?,?> field)
Clears error theme for the
field
.protected String
getErrorThemeName(ErrorLevel errorLevel)
Gets the theme name for the
ErrorLevel
.protected Optional<ThemeList>
getThemes(HasValue<?,?> field)
Gets themes for the
field
.void
handleError(HasValue<?,?> field, ValidationResult result)
Handles a validation error emitted when trying to write the value of the given field.
protected void
setErrorTheme(HasValue<?,?> field, ValidationResult result)
Sets error theme for the
field
based onresult
.
-
-
-
Method Detail
-
handleError
public void handleError(HasValue<?,?> field, ValidationResult result)
Handles a validation error emitted when trying to write the value of the given field.
Specified by:
handleError
in interfaceBinderValidationErrorHandler
Parameters:
field
- the field with the invalid valueresult
- the validation error resultSee Also:
-
clearError
public void clearError(HasValue<?,?> field)
Clears the error condition of the given field, if any.
Specified by:
clearError
in interfaceBinderValidationErrorHandler
Parameters:
field
- the field with an invalid valueSee Also:
BinderValidationErrorHandler.handleError(HasValue, ValidationResult)
-
getErrorThemeName
protected String getErrorThemeName(ErrorLevel errorLevel)
Gets the theme name for the
ErrorLevel
.Parameters:
errorLevel
- the error levelReturns:
a theme name for the error level
-
getThemes
protected Optional<ThemeList> getThemes(HasValue<?,?> field)
Gets themes for the
field
.Parameters:
field
- a fieldReturns:
an optional theme list, or an empty optional if the
field
doesn't have it
-
clearErrorTheme
protected void clearErrorTheme(HasValue<?,?> field)
Clears error theme for the
field
.Parameters:
field
- a feild
-
setErrorTheme
protected void setErrorTheme(HasValue<?,?> field, ValidationResult result)
Sets error theme for the
field
based onresult
.Parameters:
field
- a fieldresult
- a validation result
-
-