public List<InvalidValue> validate(ActionSupport actionAs, Locale clientLocale,
ClassLoader classLoader) throws IOException {
List<InvalidValue> invalidValuesFromRequest = new ArrayList<InvalidValue>();
ClassValidator actionValidator = null;
if (localesMap.containsKey(clientLocale.toString())) {
actionValidator = new ClassValidator(actionAs.getClass(),localesMap.get(clientLocale.toString()));
} else {
ResourceBundle clientDefaultMessages = ResourceBundle.getBundle("org.hibernate.validator.resources.DefaultValidatorMessages", clientLocale, this.getClass().getClassLoader());
try {
ResourceBundle clientCustomMessages = ResourceBundle.getBundle("ValidatorMessages", clientLocale);
actionValidator = new ClassValidator(actionAs.getClass(),clientCustomMessages);
localesMap.put(clientLocale.toString(), clientCustomMessages);
} catch (MissingResourceException e) {
actionValidator = new ClassValidator(actionAs.getClass(),clientDefaultMessages);
localesMap.put(clientLocale.toString(), clientDefaultMessages);
}
}
// take all errors but discard when the field do not came from the request
// Only the first validation error by field is used.
InvalidValue[] invalidValues = actionValidator.getInvalidValues(actionAs);
List<String> invalidFieldNames = new ArrayList<String>();
Map parameters = ActionContext.getContext().getParameters();
for (InvalidValue invalidValue : invalidValues) {
String fieldFullName = invalidValue.getPropertyPath();
if (invalidFieldNames.contains(fieldFullName))