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
EntityValidatorServiceImpl#validate(Entity, Serializable, Map)},
Validator},
Spring Validation Docs| Modifier and Type | Field and Description |
|---|---|
protected boolean |
useDefaultEntityValidations
If true (default behavior) this will invoke the default implementation to perform validations hooked up via
ValidationConfiguration from AdminPresentation. |
protected javax.validation.Validator |
validator |
applicationContext, globalEntityValidators, securityService| Constructor and Description |
|---|
BeanValidationEntityValidatorServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
javax.validation.Validator |
getValidator() |
boolean |
isUseDefaultEntityValidations() |
void |
setUseDefaultEntityValidations(boolean useDefaultEntityValidations) |
void |
setValidator(javax.validation.Validator validator) |
void |
validate(Entity entity,
Serializable instance,
Map<String,FieldMetadata> mergedProperties,
RecordHelper recordHelper,
boolean validateUnsubmittedProperties)
Validate the given entity.
|
getGlobalEntityValidators, getTypeHierarchy, setApplicationContext, setGlobalEntityValidators@Autowired protected javax.validation.Validator validator
protected boolean useDefaultEntityValidations
ValidationConfiguration from AdminPresentation.public BeanValidationEntityValidatorServiceImpl()
public void validate(Entity entity, Serializable instance, Map<String,FieldMetadata> mergedProperties, RecordHelper recordHelper, boolean validateUnsubmittedProperties)
EntityValidatorServiceEntity.setValidationFailure(boolean) appropriately.
Validation is invoked after the entire instance has been populated according to
BasicPersistenceModule.createPopulatedInstance(Serializable, Entity, Map, Boolean).validate in interface EntityValidatorServicevalidate in class EntityValidatorServiceImplinstance - actual domain representation of entitymergedProperties - all of the merged properties metadata for the given EntityvalidateUnsubmittedProperties - if set to true, will ignore validation for properties that weren't submitted
along with the entitypublic javax.validation.Validator getValidator()
public void setValidator(javax.validation.Validator validator)
public boolean isUseDefaultEntityValidations()
public void setUseDefaultEntityValidations(boolean useDefaultEntityValidations)
Copyright © 2015. All rights reserved.