Menu

ServerValidation.exception functionality

Help
2009-09-02
2013-04-26
  • Mohsen Saboorian

    Could you please tell me why is params vararg added with the following line to the end of msgKey?

    for(Object o: params) {
        msgKey += ":"+o.toString();
    }

    When we have public String getCustomMessage(String key, Object... parameters) with a readily available vararg 'parameters', why are parameters also appended to the end of key?

    Isn't it a bug?

     
    • Anatol Mayen

      Anatol Mayen - 2009-09-03

      Hello Mohsen,

      the ServerValidation class is supposed to be used on the server side only. It creates a ValidationException that is send to the client, encapsulating a custom key and variable arguments. On the client side the the ValidationException gets processed. The localization of the error message will be done by the getCustomMessage(String key, Object... parameters) method but only at the client side. So to transport the key+parameters to the client the method which you saw is used. On the client the message is given to the getCustomMessage method with the specific arguments.

      So this is not a bug, but a feature ;>

      But actually I found a bug with this, which I found directly after I uploaded the release. Right now the String given to getCustomMessage is "key:param1:param2" where it should only be "key", because the params are in the parameters vararg object. I think I will release another version soon as this is a really annoying mistake.

      Regards, Anatol

       
      • Nobody/Anonymous

        This was what I actually meant. It's redundant to have "key:param1:param2" as well as a vararg providing [prara1, param2] and it's also probably a bug to provide "key:param1:param2" instead of "key" in getCustomMessage, when a single key is expected.

         
  • Anatol Mayen

    Anatol Mayen - 2009-09-22

    Just to let you know I decided to NOT release another version just because I think this bug alone does not justify a new release, because you can work around it so easily.

    To get rid of it just do a:

    key = key.split(":")

    this way it should work even if the new version comes out that does not suffer this bug.

    Regards, Anatol

     

Log in to post a comment.