FieldUtils.getBindStatus(configuration, processingContext, fieldExpression);
if (bindStatus == null) {
return Collections.EMPTY_LIST;
}
final Errors errors = bindStatus.getErrors();
if (errors == null) {
return Collections.EMPTY_LIST;
}
final RequestContext requestContext =
(RequestContext) processingContext.getContext().getVariables().get(SpringContextVariableNames.SPRING_REQUEST_CONTEXT);
if (requestContext == null) {
return Collections.EMPTY_LIST;
}
final List<DetailedError> errorObjects = new ArrayList<DetailedError>(errors.getErrorCount() + 2);
if (includeGlobalErrors) {
final List<ObjectError> globalErrors = errors.getGlobalErrors();
for (final ObjectError globalError : globalErrors) {
final String message = requestContext.getMessage(globalError, false);
final DetailedError errorObject =
new DetailedError(globalError.getCode(), globalError.getArguments(), message);
errorObjects.add(errorObject);
}
}
if (includeFieldErrors) {
final List<FieldError> fieldErrors = errors.getFieldErrors();
for (final FieldError fieldError : fieldErrors) {
final String message = requestContext.getMessage(fieldError, false);
final DetailedError errorObject =
new DetailedError(fieldError.getField(), fieldError.getCode(), fieldError.getArguments(), message);
errorObjects.add(errorObject);