|
98 | 98 | * @author Rod Johnson |
99 | 99 | * @author Juergen Hoeller |
100 | 100 | * @author Rob Harrop |
| 101 | + * @author Stephane Nicoll |
101 | 102 | * @see #setAllowedFields |
102 | 103 | * @see #setRequiredFields |
103 | 104 | * @see #registerCustomEditor |
@@ -250,29 +251,50 @@ public int getAutoGrowCollectionLimit() { |
250 | 251 | * Initialize standard JavaBean property access for this DataBinder. |
251 | 252 | * <p>This is the default; an explicit call just leads to eager initialization. |
252 | 253 | * @see #initDirectFieldAccess() |
| 254 | + * @see #createBeanPropertyBindingResult() |
253 | 255 | */ |
254 | 256 | public void initBeanPropertyAccess() { |
255 | 257 | Assert.state(this.bindingResult == null, |
256 | 258 | "DataBinder is already initialized - call initBeanPropertyAccess before other configuration methods"); |
257 | | - this.bindingResult = new BeanPropertyBindingResult( |
258 | | - getTarget(), getObjectName(), isAutoGrowNestedPaths(), getAutoGrowCollectionLimit()); |
| 259 | + this.bindingResult = createBeanPropertyBindingResult(); |
| 260 | + } |
| 261 | + |
| 262 | + /** |
| 263 | + * Create the {@link AbstractPropertyBindingResult} instance using standard JavaBean |
| 264 | + * property access. |
| 265 | + */ |
| 266 | + protected AbstractPropertyBindingResult createBeanPropertyBindingResult() { |
| 267 | + BeanPropertyBindingResult result = new BeanPropertyBindingResult(getTarget(), |
| 268 | + getObjectName(), isAutoGrowNestedPaths(), getAutoGrowCollectionLimit()); |
259 | 269 | if (this.conversionService != null) { |
260 | | - this.bindingResult.initConversion(this.conversionService); |
| 270 | + result.initConversion(this.conversionService); |
261 | 271 | } |
| 272 | + return result; |
262 | 273 | } |
263 | 274 |
|
264 | 275 | /** |
265 | 276 | * Initialize direct field access for this DataBinder, |
266 | 277 | * as alternative to the default bean property access. |
267 | 278 | * @see #initBeanPropertyAccess() |
| 279 | + * @see #createDirectFieldBindingResult() |
268 | 280 | */ |
269 | 281 | public void initDirectFieldAccess() { |
270 | 282 | Assert.state(this.bindingResult == null, |
271 | 283 | "DataBinder is already initialized - call initDirectFieldAccess before other configuration methods"); |
272 | | - this.bindingResult = new DirectFieldBindingResult(getTarget(), getObjectName(), isAutoGrowNestedPaths()); |
| 284 | + this.bindingResult = createDirectFieldBindingResult(); |
| 285 | + } |
| 286 | + |
| 287 | + /** |
| 288 | + * Create the {@link AbstractPropertyBindingResult} instance using direct field |
| 289 | + * access. |
| 290 | + */ |
| 291 | + protected AbstractPropertyBindingResult createDirectFieldBindingResult() { |
| 292 | + DirectFieldBindingResult result = new DirectFieldBindingResult(getTarget(), |
| 293 | + getObjectName(), isAutoGrowNestedPaths()); |
273 | 294 | if (this.conversionService != null) { |
274 | | - this.bindingResult.initConversion(this.conversionService); |
| 295 | + result.initConversion(this.conversionService); |
275 | 296 | } |
| 297 | + return result; |
276 | 298 | } |
277 | 299 |
|
278 | 300 | /** |
|
0 commit comments