Class AUniqueEntityFieldValidator<TEntity extends de.xima.cmn.dao.interfaces.IEntity<Long>,TField>

java.lang.Object
de.xima.fc.gui.validator.name.AUniqueEntityFieldValidator<TEntity,TField>
Type Parameters:
TEntity - Type of the entity 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:
AUniqueStringFieldValidator

public abstract class AUniqueEntityFieldValidator<TEntity extends de.xima.cmn.dao.interfaces.IEntity<Long>,TField> extends Object implements javax.faces.validator.Validator, Serializable
Abstract base class for faces validators that check whether a certain field of an entity is unique amongst all existing entities within a certain scope.
Since:
7.0.0
Author:
XIMA MEDIA GmbH
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
     

    Fields inherited from interface javax.faces.validator.Validator

    NOT_IN_RANGE_MESSAGE_ID
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addScope(de.xima.cmn.criteria.QueryCriteriaManager qcm, TEntity entity)
    Use this method to restrict the scope of entities considered for the duplicate search, such as to a certain client, version, project etc.
    protected abstract void
    addSearch(de.xima.cmn.criteria.QueryCriteriaManager qcm, TField value)
    Adds the criteria an entity must match to be considered a duplicate.
    protected abstract TField
     
    protected static javax.faces.validator.ValidatorException
     
    protected static javax.faces.validator.ValidatorException
     
    protected Object
    findEntity(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
    Finds the entity to validate from the UI component.
    protected static Object
    getValueExpressionBase(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
     
    protected abstract boolean
     
    final void
    validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AUniqueEntityFieldValidator

      protected AUniqueEntityFieldValidator(Class<TEntity> entityClass, Class<TField> fieldClass)
  • Method Details

    • validate

      public final void validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value) throws javax.faces.validator.ValidatorException
      Specified by:
      validate in interface javax.faces.validator.Validator<TEntity extends de.xima.cmn.dao.interfaces.IEntity<Long>>
      Throws:
      javax.faces.validator.ValidatorException
    • addScope

      protected void addScope(de.xima.cmn.criteria.QueryCriteriaManager qcm, @Nonnull TEntity entity)
      Use this method to restrict the scope of entities considered for the duplicate search, such as to a certain client, version, project etc.

      By default, the client and project scope is set if the entity implements IMandantDependent or IProjektDependent.

      Parameters:
      qcm - Query criteria manager that will be used to check for existing duplicates.
      entity - Entity that is validated.
    • addSearch

      protected abstract void addSearch(de.xima.cmn.criteria.QueryCriteriaManager qcm, @Nonnull TField value)
      Adds the criteria an entity must match to be considered a duplicate.
      Parameters:
      qcm - Query criteria manager that will be used to check for existing duplicates.
      value - Field to search.
    • convertValue

      protected abstract TField convertValue(@Nonnull Object value)
      Parameters:
      value - Value as received from the UI.
      Returns:
      The value, converted to the expected type.
    • findEntity

      protected Object findEntity(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 use myBean.selected.name).
      Parameters:
      context - Current faces context.
      component - Component to validate.
      Returns:
      The entity with a field to validate.
    • hasValue

      protected abstract boolean hasValue(@Nonnull TField value)
      Parameters:
      value - The converted field value.
      Returns:
      true if the value is non-empty, or false otherwise. 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)