org.apache.myfaces.extensions.validator.baseval.strategy
Class JpaValidationStrategy

java.lang.Object
  extended by org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractValidationStrategy
      extended by org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractAnnotationValidationStrategy
          extended by org.apache.myfaces.extensions.validator.baseval.strategy.JpaValidationStrategy
All Implemented Interfaces:
ValidationStrategy

@NullValueAwareValidationStrategy
@EmptyValueAwareValidationStrategy
public class JpaValidationStrategy
extends AbstractAnnotationValidationStrategy

Since:
1.x.1
Author:
Gerhard Petracek

Field Summary
 
Fields inherited from class org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractAnnotationValidationStrategy
DETAIL_MESSAGE_KEY_POSTFIX
 
Fields inherited from class org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractValidationStrategy
logger
 
Constructor Summary
JpaValidationStrategy()
           
 
Method Summary
protected  String getErrorMessageDetail(Annotation annotation)
          Returns the error message (the detailed message) provided by the given constraint.
protected  String getValidationErrorMsgKey(Annotation annotation)
          Returns the key for the message that needs to be resolved for the violation-message.
protected  boolean processAfterValidatorException(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject, javax.faces.validator.ValidatorException e)
          Executes the registered ValidationExceptionInterceptor to process the validation exception.
 void processValidation(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject)
          Validates the given value based on the given meta-data entry.
protected  String resolveMessage(String key)
          Uses the given message key to resolve the actual message in the correct language.
 
Methods inherited from class org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractAnnotationValidationStrategy
getErrorMessageSummary, getLabel, getValidationErrorFacesMessage, setMessageResolver
 
Methods inherited from class org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractValidationStrategy
initValidation, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JpaValidationStrategy

public JpaValidationStrategy()
Method Detail

processValidation

public void processValidation(javax.faces.context.FacesContext facesContext,
                              javax.faces.component.UIComponent uiComponent,
                              MetaDataEntry metaDataEntry,
                              Object convertedObject)
                       throws javax.faces.validator.ValidatorException
Description copied from class: AbstractValidationStrategy
Validates the given value based on the given meta-data entry. The method throws a ValidatorException if a violation is detected

Specified by:
processValidation in class AbstractValidationStrategy
Parameters:
facesContext - The JSF Context
uiComponent - The JSF component that contained the value entered by the user.
metaDataEntry - The data holder which stores the meta-data and some information where the meta-data was around.
convertedObject - Converted object of the user entered value.
Throws:
javax.faces.validator.ValidatorException - When violation of the validation rules occurs.

getValidationErrorMsgKey

protected String getValidationErrorMsgKey(Annotation annotation)
Description copied from class: AbstractAnnotationValidationStrategy
Returns the key for the message that needs to be resolved for the violation-message.

Specified by:
getValidationErrorMsgKey in class AbstractAnnotationValidationStrategy
Parameters:
annotation - The annotation associated with the ValidationStrategy.
Returns:
The key of the error message.

getErrorMessageDetail

protected String getErrorMessageDetail(Annotation annotation)
Description copied from class: AbstractAnnotationValidationStrategy
Returns the error message (the detailed message) provided by the given constraint. The message is determined by using the AbstractAnnotationValidationStrategy.getValidationErrorMsgKey(A) method for obtaining the message-/key which then is resolved by the method resolveMessage. When the key isn't found, the resulting exception is just logged but not propagated. So the detail message isn't required and null is returned instead.

Overrides:
getErrorMessageDetail in class AbstractAnnotationValidationStrategy
Parameters:
annotation - The annotation associated with the ValidationStrategy.
Returns:
The error message used in the detail part of the FacesMessage or null.

resolveMessage

protected String resolveMessage(String key)
Description copied from class: AbstractAnnotationValidationStrategy
Uses the given message key to resolve the actual message in the correct language. The current UIViewRoot provides the target locale. When a MessageResolver is available, it is used to resolve the message. Otherwise the default rules are taken to define the MessageResolver. ExtValUtils.getMessageResolverForValidationStrategy( org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy)

Overrides:
resolveMessage in class AbstractAnnotationValidationStrategy
Parameters:
key - key of the error message that needs to be resolved.
Returns:
Resolved message.

processAfterValidatorException

protected boolean processAfterValidatorException(javax.faces.context.FacesContext facesContext,
                                                 javax.faces.component.UIComponent uiComponent,
                                                 MetaDataEntry metaDataEntry,
                                                 Object convertedObject,
                                                 javax.faces.validator.ValidatorException e)
Description copied from class: AbstractAnnotationValidationStrategy
Executes the registered ValidationExceptionInterceptor to process the validation exception. Adds the label of the component to the MetaDataEntry.

Overrides:
processAfterValidatorException in class AbstractAnnotationValidationStrategy
Parameters:
facesContext - The JSF Context
uiComponent - The JSF component that contained the value entered by the user.
metaDataEntry - The data holder which stores the meta-data and some information where the meta-data was around.
convertedObject - Converted object of the user entered value.
e - The validation exception that occurred.
Returns:
should return true when you like to have the ValidatorException thrown by the ExtValUtils#tryToThrowValidatorExceptionForComponent method. ExtValUtils.tryToThrowValidatorExceptionForComponent(javax.faces.component.UIComponent, javax.faces.application.FacesMessage, java.lang.Throwable)


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.