Ensure getField(String) wildcard support with SF 6.1+
Closes gh-1814
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2012 the original author or authors.
|
* Copyright 2004-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -37,6 +37,7 @@ import org.springframework.binding.message.MessageContext;
|
|||||||
import org.springframework.binding.message.MessageCriteria;
|
import org.springframework.binding.message.MessageCriteria;
|
||||||
import org.springframework.binding.message.Severity;
|
import org.springframework.binding.message.Severity;
|
||||||
import org.springframework.core.convert.TypeDescriptor;
|
import org.springframework.core.convert.TypeDescriptor;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.validation.AbstractErrors;
|
import org.springframework.validation.AbstractErrors;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
@@ -127,6 +128,12 @@ public class BindingModel extends AbstractErrors implements BindingResult {
|
|||||||
return toErrors(messageContext.getMessagesByCriteria(messageCriteria), FIELD_ERRORS);
|
return toErrors(messageContext.getMessagesByCriteria(messageCriteria), FIELD_ERRORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override to ensure use of overridden getFieldErrors(String)
|
||||||
|
public FieldError getFieldError(String field) {
|
||||||
|
List<FieldError> fieldErrors = getFieldErrors(field);
|
||||||
|
return (!fieldErrors.isEmpty() ? fieldErrors.get(0) : null);
|
||||||
|
}
|
||||||
|
|
||||||
public Class<?> getFieldType(String field) {
|
public Class<?> getFieldType(String field) {
|
||||||
return parseFieldExpression(fixedField(field), false).getValueType(boundObject);
|
return parseFieldExpression(fixedField(field), false).getValueType(boundObject);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user