-
Feb 11th, 2011, 02:02 AM
#1
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 "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 "typeMismatch.java.lang.Double"
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,typeMismatch.java.lang.Doubl e,typeMismatch]; arguments [org.springframework.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: "s"]
Last edited by enimsaj; Feb 18th, 2011 at 11:06 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules