Back Forum Reply New

Modify FieldError object contained in BindingResult

Hi:

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 quot;typeMismatch.loanProduct.loanAmountByLastLoanAmou  nt[0].upperquot;   2. try quot;typeMismatch.loanProduct.loanAmountByLastLoanAmou  nt.upperquot;   3. try quot;typeMismatch.loanAmountByLastLoanAmount[0].upperquot;   4. try quot;typeMismatch.loanAmountByLastLoanAmount.upper  quot;   5. try quot;typeMismatch.upperquot;   6. try quot;typeMismatch.java.lang.Doublequot;   7. try quot;typeMismatchquot;  

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,typeMismatch.java.lang.Doubl  e,typeMismatch]; arguments [org..context.support.DefaultMessage  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: quot;squot;]
¥
Back Forum Reply New