@@ -0,0 +1,2009 @@
+/*%0A * Copyright 2009-2011 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage info.joseluismartin.gui.bind;%0A%0Aimport org.springframework.beans.PropertyAccessException;%0Aimport org.springframework.util.ObjectUtils;%0Aimport org.springframework.util.StringUtils;%0Aimport org.springframework.validation.BindingResult;%0Aimport org.springframework.validation.DefaultBindingErrorProcessor;%0A%0A/**%0A * @author Jose Luis Martin - (jlm@joseluismartin.info)%0A */%0Apublic class ControlBindingErrorProcessor extends DefaultBindingErrorProcessor %7B%0A%0A%09/** %0A%09 * Add a ControlError instead FieldError to hold component that has failed.%0A%09 * @param control%0A%09 * @param ex%0A%09 * @param bindingResult%0A%09 */%0A%09public void processPropertyAccessException(Object control, PropertyAccessException ex, %0A%09%09%09BindingResult bindingResult ) %7B%0A%09%09// Create field error with the exceptions's code, e.g. %22typeMismatch%22.%0A%09%09String field = ex.getPropertyName();%0A%09%09String%5B%5D codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field);%0A%09%09Object%5B%5D arguments = getArgumentsForBindError(bindingResult.getObjectName(), field);%0A%09%09Object rejectedValue = ex.getValue();%0A%09%09if (rejectedValue != null && rejectedValue.getClass().isArray()) %7B%0A%09%09%09rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue));%0A%09%09%7D%0A%09%09bindingResult.addError(new ControlError(control,%0A%09%09%09%09bindingResult.getObjectName(), field, rejectedValue, true,%0A%09%09%09%09codes, arguments, ex.getLocalizedMessage()));%0A%09%7D%0A%7D%0A

Add method to DefaultControlErrorProcessor for hold the swing control