Results 1 to 6 of 6

Thread: errors.reject with Object[] errorArgs. Bug?

  1. #1

    Default errors.reject with Object[] errorArgs. Bug?

    Hi. I have problem with code:

    protected void onBindAndValidate(HttpServletRequest request,
    Object command,
    BindException errors)
    throws Exception {

    if (blabla > 7)
    errors.reject("bla.bla", new Object[]{7}, "My default message");

    }

    bla.bla=You must select up to {0} categories

    But it is not working. I get message with {0} in text.

    Is it Spring bug?
    Can anybody help me?

  2. #2
    Join Date
    May 2008
    Posts
    2

    Default

    I am having this exact same issue. This seems like a pretty core method -- I'd be surprised if it is not working correctly. What are we doing wrong??

  3. #3
    Join Date
    Dec 2006
    Posts
    311

    Default

    This is just a guess but try wrapping that int in Integer:

    Code:
    errors.reject("bla.bla", new Object[]{new Integer(7)}, "My default message");
    Also, I dont think this is the cause of your problem but you are registering a global error and not a field error. It seems like you would want to register a field error in your case.

  4. #4
    Join Date
    May 2008
    Posts
    2

    Default

    Thanks for the reply. My code is slightly different; I am already using Objects, so the proposed solution doesn't apply to me. Here is what I am doing:

    in the validator:

    Code:
    String identifier = "12345678-G";
    String name = "moo";
    errors.reject("error.checkdigits.unallowed", new Object[]{identifier, moo}, "The identifier is not supported by the validation scheme");
    in messages.properties:

    Code:
    error.checkdigits.unallowed=The identifier {0} is not allowed for validator {1}
    output upon error:

    Code:
    The identifier {0} is not allowed for validator {1}
    For whatever reason, {0} and {1} aren't being replaced by "12345678-G" and "moo".

  5. #5
    Join Date
    Oct 2005
    Posts
    18

    Default

    I have the same exact issue.

  6. #6
    Join Date
    Apr 2009
    Posts
    18

    Default

    is this issue solved?. i still have this issue

Posting Permissions

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