Class BeanValidationInterceptor
java.lang.Object
org.apache.struts2.interceptor.AbstractInterceptor
org.apache.struts2.interceptor.MethodFilterInterceptor
org.apache.struts.beanvalidation.validation.interceptor.BeanValidationInterceptor
- All Implemented Interfaces:
- Serializable,- ConditionalInterceptor,- Interceptor
Bean Validation interceptor. This Interceptor does not itself provide any Bean validation functionality but works as a bridge between Bean validation implementations like Apache Bval or Hibernate Validator and Struts2 validation mechanism.
Interceptor will create a Validation Factory based on the provider class and will validate requested method or Action class. Hibernate bean validator will be used as a default validator in case of no provider class will be supplied to the interceptor.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected BeanValidationManagerprotected Stringprotected booleanprotected TextProviderFactoryFields inherited from class org.apache.struts2.interceptor.MethodFilterInterceptorexcludeMethods, includeMethods
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddBeanValidationErrors(Set<jakarta.validation.ConstraintViolation<Object>> constraintViolations, Object action) protected org.apache.struts.beanvalidation.validation.interceptor.BeanValidationInterceptor.ValidationErrorbuildBeanValidationError(jakarta.validation.ConstraintViolation<Object> violation, String message) protected StringdoIntercept(ActionInvocation invocation) protected MethodgetActionMethod(Class<?> actionClass, String methodName) This is copied from DefaultActionInvocationprotected Class<?>[]getValidationGroups(Object action, String methodName) protected booleanisActionError(jakarta.validation.ConstraintViolation<Object> violation) Decide if a violation should be added to the fieldErrors or actionErrorsprotected voidperformBeanValidation(Object action, jakarta.validation.Validator validator, Class<?>[] groups) voidsetBeanValidationManager(BeanValidationManager beanValidationManager) voidsetConvertFromEncoding(String convertFromEncoding) voidsetConvertToUtf8(String convertToUtf8) voidsetTextProviderFactory(TextProviderFactory textProviderFactory) Methods inherited from class org.apache.struts2.interceptor.MethodFilterInterceptorapplyInterceptor, getExcludeMethodsSet, getIncludeMethodsSet, intercept, setExcludeMethods, setIncludeMethodsMethods inherited from class org.apache.struts2.interceptor.AbstractInterceptordestroy, init, setDisabled, shouldIntercept
- 
Field Details- 
beanValidationManager
- 
textProviderFactory
- 
convertToUtf8protected boolean convertToUtf8
- 
convertFromEncoding
 
- 
- 
Constructor Details- 
BeanValidationInterceptorpublic BeanValidationInterceptor()
 
- 
- 
Method Details- 
setBeanValidationManager
- 
setTextProviderFactory
- 
setConvertToUtf8
- 
setConvertFromEncoding
- 
doIntercept- Specified by:
- doInterceptin class- MethodFilterInterceptor
- Throws:
- Exception
 
- 
getValidationGroupsprotected Class<?>[] getValidationGroups(Object action, String methodName) throws NoSuchMethodException - Throws:
- NoSuchMethodException
 
- 
performBeanValidation
- 
addBeanValidationErrors
- 
buildBeanValidationError
- 
isActionErrorDecide if a violation should be added to the fieldErrors or actionErrors- Parameters:
- violation- the violation
- Returns:
- true if violation should be added to the fieldErrors or actionErrors
 
- 
getActionMethodprotected Method getActionMethod(Class<?> actionClass, String methodName) throws NoSuchMethodException This is copied from DefaultActionInvocation- Parameters:
- actionClass- the action class
- methodName- the method name
- Returns:
- Method
- Throws:
- NoSuchMethodException- if no method with this name was found
 
 
-