Announcement Announcement Module
Collapse
No announcement yet.
errors.reject with Object[] errorArgs. Bug? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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??

    Comment


    • #3
      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.

      Comment


      • #4
        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".

        Comment


        • #5
          I have the same exact issue.

          Comment


          • #6
            is this issue solved?. i still have this issue

            Comment

            Working...
            X