Announcement Announcement Module
No announcement yet.
Modify FieldError object contained in BindingResult Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Modify FieldError object contained in BindingResult


    I have a form which binds to an array. I have a validator and for validation error messages I'm able to append an ObjectError object to the BindingResult object with the customized error message.

    When I get a typeMismatch error which is a binding error, the DefaultMessageCodesResolver has the following choices for codes:

    1. try "typeMismatch.loanProduct.loanAmountByLastLoanAmou nt[0].upper"
    2. try "typeMismatch.loanProduct.loanAmountByLastLoanAmou nt.upper"
    3. try "typeMismatch.loanAmountByLastLoanAmount[0].upper"
    4. try "typeMismatch.loanAmountByLastLoanAmount.upper "
    5. try "typeMismatch.upper"
    6. try ""
    7. try "typeMismatch"

    I'm using the second code:
    2. typeMismatch.loanProduct.loanAmountByLastLoanAmoun t.upper

    which works fine, except that I would like to pass it an argument for message resolution. Is there a way to update the arguments used to resolve the message that are associated with this FieldError, which is contained in BindingResult?

    Looking in the debugger, the BindingResult object contains the following FieldError associated with the typeMismatch error. As shown below, the arguments used to resolve the message are empty, arguments []; and I would like to change this to be 1 or 2, basically an integer.
    Field error in object 'loanProduct' on field 'loanAmountByLastLoanAmount[0].upper': rejected value [s]; codes [typeMismatch.loanProduct.loanAmountByLastLoanAmoun t[0].upper,typeMismatch.loanProduct.loanAmountByLastLo anAmount.upper,typeMismatch.loanAmountByLastLoanAm ount[0].upper,typeMismatch.loanAmountByLastLoanAmount.upp er,typeMismatch.upper, e,typeMismatch]; arguments [ SourceResolvable: codes [loanProduct.loanAmountByLastLoanAmount[0].upper,loanAmountByLastLoanAmount[0].upper]; arguments []; default message [loanAmountByLastLoanAmount[0].upper]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Double' for property 'loanAmountByLastLoanAmount[0].upper'; nested exception is java.lang.NumberFormatException: For input string: "s"]
    Last edited by enimsaj; Feb 18th, 2011, 12:06 PM.