Results 1 to 2 of 2

Thread: DefaultMessageCodesResolver substitutions

  1. #1
    Join Date
    Nov 2004
    Location
    Washington, DC
    Posts
    9

    Default DefaultMessageCodesResolver substitutions

    (Sorry for repost from springframework-user, but I got no answer there)

    I am using the DefaultMessageCodesResolver and I setup an error message
    for failure to bind to an Integer field:

    typeMismatch.java.lang.Integer={0} must be a whole number.

    The problem is, {0} is resolved as the field name instead of the
    resolved natural-language representation of the field's name. In my
    example, the property that I am working with is called 'port' and in
    English the field name is 'Port' so I am getting the message 'port must
    be a whole number.' instead of 'Port must be a whole number.'

    I know I could define a message called typeMismatch.port=Port must be a
    whole number. but that would require a new resource bundle definition
    for every Integer field in my application.

    Has anyone run into this issue before that has a simple solution?

    Thanks,

    Matt

  2. #2
    Join Date
    Jul 2009
    Posts
    6

    Default

    Sorry to wake up this old sleeping thread, but I have the same problem as sgarlatm. I must show human readable text instead of java variable.

    Code:
    @InitBinder("sector")
    public void initBinder(WebDataBinder binder) {
    	String[] fields = {"sectorID", "name", "ingate", "outgate", "effms", "lotDeletion", "lotsetDeletion", "prodCode"};
    	binder.setAllowedFields(fields);
    	binder.setRequiredFields(fields);
    }
    In validation.properties
    Code:
    required={0} - Ce champ doit contenir une valeur.
    With this, Spring shows the variable name.
    Code:
    sectorID - Ce champ ...
    name - Ce champ ...
    ...
    Someone have found a way to do this? To show human readable text instead of variable?

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •