@Override public void addAllErrors(Errors errors) { this.source.addAllErrors(errors); }
@Override public void addAllErrors(Errors errors) { this.source.addAllErrors(errors); }
@Test public void testAddAllErrors() { TestBean rod = new TestBean(); DataBinder binder = new DataBinder(rod, "person"); MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("age", "32x"); binder.bind(pvs); Errors errors = binder.getBindingResult(); BeanPropertyBindingResult errors2 = new BeanPropertyBindingResult(rod, "person"); errors.rejectValue("name", "badName"); errors.addAllErrors(errors2); FieldError ageError = errors.getFieldError("age"); assertEquals("typeMismatch", ageError.getCode()); FieldError nameError = errors.getFieldError("name"); assertEquals("badName", nameError.getCode()); }
/** * Make sure a <i>valid</i> Errors instance for given form object is exposed in given context. */ private void ensureFormErrorsExposed(RequestContext context, Object formObject) throws Exception { if (!formErrorsExposed(context)) { // initialize and expose a fresh errors instance to the flow with // editors applied initFormErrors(context, formObject); } else { // trying to reuse an existing errors instance if (formErrorsValid(context, formObject)) { // reapply property editors against the existing errors instance reinstallPropertyEditors(context); } else { // the existing errors instance seems to be invalid // initialize a new errors instance, but copy over error information if (logger.isInfoEnabled()) { logger.info("Fixing inconsistent Errors instance: initializing a new Errors instance " + "wrapping from object '" + formObject + "' in scope '" + getFormErrorsScope() + "' and copying over all existing error information."); } Errors invalidExistingErrors = getFormObjectAccessor(context).getFormErrors(getFormObjectName(), getFormErrorsScope()); Errors newErrors = initFormErrors(context, formObject); newErrors.addAllErrors(invalidExistingErrors); } } }
@Override public void addAllErrors(Errors errors) { this.source.addAllErrors(errors); }
@Override public void addAllErrors(Errors errors) { this.source.addAllErrors(errors); }
public void addAllErrors(Errors errors) { this.source.addAllErrors(errors); }
/** * Make sure a <i>valid</i> Errors instance for given form object is exposed in given context. */ private void ensureFormErrorsExposed(RequestContext context, Object formObject) throws Exception { if (!formErrorsExposed(context)) { // initialize and expose a fresh errors instance to the flow with // editors applied initFormErrors(context, formObject); } else { // trying to reuse an existing errors instance if (formErrorsValid(context, formObject)) { // reapply property editors against the existing errors instance reinstallPropertyEditors(context); } else { // the existing errors instance seems to be invalid // initialize a new errors instance, but copy over error information if (logger.isInfoEnabled()) { logger.info("Fixing inconsistent Errors instance: initializing a new Errors instance " + "wrapping from object '" + formObject + "' in scope '" + getFormErrorsScope() + "' and copying over all existing error information."); } Errors invalidExistingErrors = getFormObjectAccessor(context).getFormErrors(getFormObjectName(), getFormErrorsScope()); Errors newErrors = initFormErrors(context, formObject); newErrors.addAllErrors(invalidExistingErrors); } } }
/** * Make sure a <i>valid</i> Errors instance for given form object is exposed in given context. */ private void ensureFormErrorsExposed(RequestContext context, Object formObject) throws Exception { if (!formErrorsExposed(context)) { // initialize and expose a fresh errors instance to the flow with // editors applied initFormErrors(context, formObject); } else { // trying to reuse an existing errors instance if (formErrorsValid(context, formObject)) { // reapply property editors against the existing errors instance reinstallPropertyEditors(context); } else { // the existing errors instance seems to be invalid // initialize a new errors instance, but copy over error information if (logger.isInfoEnabled()) { logger.info("Fixing inconsistent Errors instance: initializing a new Errors instance " + "wrapping from object '" + formObject + "' in scope '" + getFormErrorsScope() + "' and copying over all existing error information."); } Errors invalidExistingErrors = getFormObjectAccessor(context).getFormErrors(getFormObjectName(), getFormErrorsScope()); Errors newErrors = initFormErrors(context, formObject); newErrors.addAllErrors(invalidExistingErrors); } } }
/** * Make sure a <i>valid</i> Errors instance for given form object is exposed in given context. */ private void ensureFormErrorsExposed(RequestContext context, Object formObject) throws Exception { if (!formErrorsExposed(context)) { // initialize and expose a fresh errors instance to the flow with // editors applied initFormErrors(context, formObject); } else { // trying to reuse an existing errors instance if (formErrorsValid(context, formObject)) { // reapply property editors against the existing errors instance reinstallPropertyEditors(context); } else { // the existing errors instance seems to be invalid // initialize a new errors instance, but copy over error information if (logger.isInfoEnabled()) { logger.info("Fixing inconsistent Errors instance: initializing a new Errors instance " + "wrapping from object '" + formObject + "' in scope '" + getFormErrorsScope() + "' and copying over all existing error information."); } Errors invalidExistingErrors = getFormObjectAccessor(context).getFormErrors(getFormObjectName(), getFormErrorsScope()); Errors newErrors = initFormErrors(context, formObject); newErrors.addAllErrors(invalidExistingErrors); } } }