validator = context.getApplication().createValidator(validatorId);
// special things to configure for a BeanValidator
if (validator instanceof BeanValidator)
{
BeanValidator beanValidator = (BeanValidator) validator;
// check the validationGroups
String validationGroups = beanValidator.getValidationGroups();
if (validationGroups == null
|| validationGroups.matches(BeanValidator.EMPTY_VALIDATION_GROUPS_PATTERN))
{
// no validationGroups available
// --> get the validationGroups from the stack
//String stackGroup = mctx.getFirstValidationGroupFromStack();
//if (stackGroup != null)
//{
// validationGroups = stackGroup;
//}
//else
//{
// no validationGroups on the stack
// --> set the default validationGroup
validationGroups = javax.validation.groups.Default.class.getName();
//}
beanValidator.setValidationGroups(validationGroups);
}
}
// add the validator to the component
component.addValidator(validator);