Example usage for org.springframework.beans PropertyAccessException getLocalizedMessage

List of usage examples for org.springframework.beans PropertyAccessException getLocalizedMessage

Introduction

In this page you can find the example usage for org.springframework.beans PropertyAccessException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.jdal.ui.bind.ControlBindingErrorProcessor.java

/** 
 * Add a ControlError instead FieldError to hold component that has failed.
 * @param control// w  w w  .j  a  va2 s.  c  o  m
 * @param ex
 * @param bindingResult
 */
public void processPropertyAccessException(Object control, PropertyAccessException ex,
        BindingResult bindingResult) {
    // Create field error with the exceptions's code, e.g. "typeMismatch".
    String field = ex.getPropertyName();
    String[] codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field);
    Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), field);
    Object rejectedValue = ex.getValue();
    if (rejectedValue != null && rejectedValue.getClass().isArray()) {
        rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue));
    }
    bindingResult.addError(new ControlError(control, bindingResult.getObjectName(), field, rejectedValue, true,
            codes, arguments, ex.getLocalizedMessage()));
}