Class AUniqueBeanFieldValidator<TBean,TField>
java.lang.Object
de.xima.fc.gui.common.validator.AUniqueBeanFieldValidator<TBean,TField>
- Type Parameters:
TBean- Type of the bean owning the field.TField- Type of the field to which the validator applies.
- All Implemented Interfaces:
Serializable, EventListener, javax.faces.validator.Validator
- Direct Known Subclasses:
AUniqueBeanStringFieldValidator, AUniqueEntityFieldValidator
public abstract class AUniqueBeanFieldValidator<TBean,TField>
extends Object
implements javax.faces.validator.Validator, Serializable
Abstract base class for faces validators that check whether a certain field of a bean is unique amongst all existing
entities (within a certain scope).
- Since:
- 8.2.0
- Author:
- XIMA MEDIA GmbH
- See Also:
-
Field Summary
FieldsFields inherited from interface javax.faces.validator.Validator
NOT_IN_RANGE_MESSAGE_ID -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAUniqueBeanFieldValidator(Class<TBean> beanClass, Class<TField> fieldClass) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TFieldconvertValue(Object value) protected static javax.faces.validator.ValidatorExceptionprotected static javax.faces.validator.ValidatorExceptionprotected ObjectfindBean(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) Finds the entity to validate from the UI component.protected static ObjectgetValueExpressionBase(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) protected booleanhasDuplicates(TBean bean, TField value) Deprecated.protected booleanhasDuplicates(TBean bean, TField value, javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) Checks if any duplicates exists for the given bean with the given field value.protected abstract booleanfinal voidvalidate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value)
-
Field Details
-
ATTR_VALUE
- See Also:
-
beanClass
-
fieldClass
-
-
Constructor Details
-
AUniqueBeanFieldValidator
-
-
Method Details
-
validate
-
convertValue
-
findBean
protected Object findBean(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) Finds the entity to validate from the UI component. The default implementation attempts to read the entity from the value expression base (e.g. when you usemyBean.selected.name).- Parameters:
context- Current faces context.component- Component to validate.- Returns:
- The entity with a field to validate.
-
hasDuplicates
protected boolean hasDuplicates(TBean bean, TField value, javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) throws Exception Checks if any duplicates exists for the given bean with the given field value.- Parameters:
bean- Bean to check for existing duplicates.value- Field value to check for duplicates.context- Current faces context.component- Component to validate.- Throws:
Exception
-
hasDuplicates
Deprecated.OverwritehasDuplicates(Object, Object, FacesContext, UIComponent)instead.Checks if any duplicates exists for the given bean with the given field value.- Parameters:
bean- Bean to check for existing duplicates.value- Field value to check for duplicates.- Throws:
Exception
-
hasValue
- Parameters:
value- The converted field value.- Returns:
trueif the value is non-empty, orfalseotherwise. When empty, this validator is skipped.
-
createError
protected static javax.faces.validator.ValidatorException createError() throws javax.faces.validator.ValidatorException- Throws:
javax.faces.validator.ValidatorException
-
createError
protected static javax.faces.validator.ValidatorException createError(Throwable e) throws javax.faces.validator.ValidatorException - Throws:
javax.faces.validator.ValidatorException
-
getValueExpressionBase
protected static Object getValueExpressionBase(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
-
hasDuplicates(Object, Object, FacesContext, UIComponent)instead.