private ExceptionDetails getBindValidationExceptionDetails(Throwable rootFailure) { BindValidationException validationException = findCause(rootFailure, BindValidationException.class); if (validationException != null) { BindException target = findCause(rootFailure, BindException.class); List<ObjectError> errors = validationException.getValidationErrors() .getAllErrors(); return new ExceptionDetails(errors, target, validationException); } org.springframework.validation.BindException bindException = findCause( rootFailure, org.springframework.validation.BindException.class); if (bindException != null) { List<ObjectError> errors = bindException.getAllErrors(); return new ExceptionDetails(errors, bindException.getTarget(), bindException); } return null; }
/** * Show the first page as form view. * <p>This can be overridden in subclasses, e.g. to prepare wizard-specific * error views in case of an Exception. */ @Override protected ModelAndView showForm( RenderRequest request, RenderResponse response, BindException errors) throws Exception { return showPage(request, errors, getInitialPage(request, errors.getTarget())); }
/** * Check if the Errors instance available in given context is valid for given form object. */ private boolean formErrorsValid(RequestContext context, Object formObject) { Errors errors = getFormObjectAccessor(context).getFormErrors(getFormObjectName(), getFormErrorsScope()); if (errors instanceof BindException) { BindException be = (BindException) errors; if (be.getTarget() != formObject) { if (logger.isInfoEnabled()) { logger.info("Inconsistency detected: the Errors instance in '" + getFormErrorsScope() + "' does NOT wrap the current form object '" + formObject + "' of class " + formObject.getClass() + "; instead this Errors instance unexpectedly wraps the target object '" + be.getTarget() + "' of class: " + be.getTarget().getClass() + "."); } return false; } else { return true; } } else { return true; } }
String formAttrName = getFormSessionAttributeName(request); if (logger.isDebugEnabled()) { logger.debug("Setting form session attribute [" + formAttrName + "] to: " + errors.getTarget()); request.getPortletSession().setAttribute(formAttrName, errors.getTarget()); Map referenceData = referenceData(request, errors.getTarget(), errors); if (referenceData != null) { model.putAll(referenceData);
throws Exception { if (page >= 0 && page < getPageCount(request, errors.getTarget())) { if (logger.isDebugEnabled()) { logger.debug("Showing wizard page " + page + " for form bean '" + getCommandName() + "'"); controlModel.put(this.pageAttribute, new Integer(page)); String viewName = getViewName(request, errors.getTarget(), page); return showForm(request, errors, viewName, controlModel);
if (request.getAttribute(ERRORS) == null) { request.setAttribute(ERRORS, errors); request.setAttribute(be.getObjectName(), be.getTarget()); return new ModelAndView(new InternalResourceView(form.concat(form.contains("?") ? "&" : "?").concat("_error=true")));
if (request.getAttribute(ERRORS) == null) { request.setAttribute(ERRORS, errors); request.setAttribute(be.getObjectName(), be.getTarget()); return new ModelAndView(new InternalResourceView(form.concat(form.contains("?") ? "&" : "?").concat("_error=true")));