1 16 17 package org.springframework.validation; 18 19 import java.io.Serializable ; 20 21 import org.springframework.beans.BeanWrapper; 22 import org.springframework.beans.BeanWrapperImpl; 23 import org.springframework.beans.ConfigurablePropertyAccessor; 24 import org.springframework.util.Assert; 25 26 43 public class BeanPropertyBindingResult extends AbstractPropertyBindingResult implements Serializable { 44 45 private final Object target; 46 47 private transient BeanWrapper beanWrapper; 48 49 50 56 public BeanPropertyBindingResult(Object target, String objectName) { 57 super(objectName); 58 Assert.notNull(target, "Target bean must not be null"); 59 this.target = target; 60 } 61 62 public final Object getTarget() { 63 return this.target; 64 } 65 66 71 public final ConfigurablePropertyAccessor getPropertyAccessor() { 72 if (this.beanWrapper == null) { 73 this.beanWrapper = createBeanWrapper(); 74 this.beanWrapper.setExtractOldValueForEditor(true); 75 } 76 return this.beanWrapper; 77 } 78 79 83 protected BeanWrapper createBeanWrapper() { 84 return new BeanWrapperImpl(getTarget()); 85 } 86 87 } 88 | Popular Tags |