org.broadleafcommerce.openadmin.server.service.persistence.validation
Class BeanValidationEntityValidatorServiceImpl
java.lang.Object
org.broadleafcommerce.openadmin.server.service.persistence.validation.EntityValidatorServiceImpl
org.broadleafcommerce.openadmin.server.service.persistence.validation.BeanValidationEntityValidatorServiceImpl
- All Implemented Interfaces:
- EntityValidatorService
public class BeanValidationEntityValidatorServiceImpl
- extends EntityValidatorServiceImpl
Implementation of the EntityValidatorService that runs entities through JSR-303 validations. The default
behavior of this implementation is to use the out-of-the-box Broadleaf validations (through ValidationConfiguration
in addition to any JSR-303 annotations that you have configured on your entity.
In order to use this validator rather than the default, you will need to include an implementation of Validator
in your Spring root application context (not the servlet). For example, you would modify your applicationContext-admin.xml
to inject Spring's default implementation of Validator (the one used by Spring MVC):
<bean class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
Then override the the blEntityValidatorService bean to use this class instead:
<bean id="blEntityValidatorService"
class="org.broadleafcommerce.openadmin.server.service.persistence.validation.BeanValidationEntityValidatorServiceImpl"/>
For more information on the default Spring JSR-303 validator, check out the docs at
- Author:
- Phillip Verheyden
- See Also:
EntityValidatorServiceImpl#validate(Entity, Serializable, Map)},
Validator},
Spring Validation Docs
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
validator
@Autowired
protected javax.validation.Validator validator
useDefaultEntityValidations
protected boolean useDefaultEntityValidations
- If true (default behavior) this will invoke the default implementation to perform validations hooked up via
ValidationConfiguration from AdminPresentation.
BeanValidationEntityValidatorServiceImpl
public BeanValidationEntityValidatorServiceImpl()
validate
public void validate(Entity entity,
Serializable instance,
Map<String,FieldMetadata> mergedProperties)
throws InstantiationException,
IllegalAccessException,
ClassNotFoundException
- Description copied from interface:
EntityValidatorService
- Validate the given entity. Implementers should set
Entity.setValidationFailure(boolean) appropriately.
- Specified by:
validate in interface EntityValidatorService- Overrides:
validate in class EntityValidatorServiceImpl
- Parameters:
entity - DTO representation of instanceinstance - actual domain representation of entitymergedProperties - all of the merged properties including metadata
- Throws:
InstantiationException
IllegalAccessException
ClassNotFoundException
getValidator
public javax.validation.Validator getValidator()
setValidator
public void setValidator(javax.validation.Validator validator)
isUseDefaultEntityValidations
public boolean isUseDefaultEntityValidations()
setUseDefaultEntityValidations
public void setUseDefaultEntityValidations(boolean useDefaultEntityValidations)
Copyright © 2013. All Rights Reserved.