|
26 | 26 | import groovy.lang.MissingMethodException; |
27 | 27 | import groovy.lang.MissingPropertyException; |
28 | 28 |
|
| 29 | +import java.beans.PropertyDescriptor; |
29 | 30 | import java.beans.PropertyEditor; |
30 | 31 | import java.math.BigDecimal; |
31 | 32 | import java.math.BigInteger; |
|
71 | 72 | import org.codehaus.groovy.runtime.InvokerHelper; |
72 | 73 | import org.codehaus.groovy.runtime.MetaClassHelper; |
73 | 74 | import org.codehaus.groovy.runtime.metaclass.ThreadManagedMetaBeanProperty; |
| 75 | +import org.springframework.beans.BeanUtils; |
74 | 76 | import org.springframework.beans.BeanWrapper; |
75 | 77 | import org.springframework.beans.BeanWrapperImpl; |
76 | 78 | import org.springframework.beans.ConfigurablePropertyAccessor; |
@@ -512,14 +514,29 @@ private void filterNestedParameterMaps(MutablePropertyValues mpvs) { |
512 | 514 | if (JSONObject.NULL.getClass().isInstance(value)) { |
513 | 515 | mpvs.removePropertyValue(pv); |
514 | 516 | } |
515 | | - if (isNotCandidateForBinding(value)) { |
| 517 | + if (!isCandidateForBinding(pv)) { |
516 | 518 | mpvs.removePropertyValue(pv); |
517 | 519 | } |
518 | 520 | } |
519 | 521 | } |
520 | 522 |
|
521 | | - private boolean isNotCandidateForBinding(Object value) { |
522 | | - return value instanceof Map; |
| 523 | + private boolean isCandidateForBinding(PropertyValue pv) { |
| 524 | + boolean isCandidate = true; |
| 525 | + final Object value = pv.getValue(); |
| 526 | + if(value instanceof GrailsParameterMap || value instanceof JSONObject) { |
| 527 | + isCandidate = false; |
| 528 | + } else if(value instanceof Map) { |
| 529 | + isCandidate = false; |
| 530 | + final String propertyName = pv.getName(); |
| 531 | + final PropertyDescriptor property = BeanUtils.getPropertyDescriptor(getTarget().getClass(), propertyName); |
| 532 | + if(property != null) { |
| 533 | + final Class<?> propertyType = property.getPropertyType(); |
| 534 | + if(propertyType.isAssignableFrom(value.getClass())) { |
| 535 | + isCandidate = true; |
| 536 | + } |
| 537 | + } |
| 538 | + } |
| 539 | + return isCandidate; |
523 | 540 | } |
524 | 541 |
|
525 | 542 | private PropertyValues filterPropertyValues(PropertyValues propertyValues, String prefix) { |
|
0 commit comments