Results 1 to 6 of 6

Thread: Getting error message from ValidationException

  1. #1
    Join Date
    Feb 2008
    Posts
    28

    Default Getting error message from ValidationException

    Hi,

    I am using the org.springframework.batch.item.validator.SpringVal idator along with org.springmodules.validation.valang.ValangValidato r.

    This is as shown in the spring batch tutorial of validating errors.

    Validating Input

    I am able to do validation successfully. But I have problem in getting the error messages. I get a org.springframework.batch.item.validator.Validatio nException and then when i try to do e.getMessage(), I am not getting the error messages in a friendly way, I am getting it something like this

    Validation failed for com.sample.example.model.VariableField@35c41b:
    Field error in object 'item' on field 'variableDataValue': rejected value []; codes [variableDataValue.item.variableDataValue,variableD ataValue.variableDataValue,variableDataValue.java. lang.String,variableDataValue]; arguments []; default message [variable.data.value.required]

    The value i am expecting is just the key "variable.data.value.required"

    Is there any way to get only the keys?

    Thanks
    Venkatesh

  2. #2
    Join Date
    Nov 2008
    Posts
    8

    Default User Friendly Message from Valang Exception

    Has anyone got a solution to this? I'm in exactly the same position so would appreciate any response.

  3. #3
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    If you raise a JIRA we can put a BindException in as the cause of the ValidationException. Would that work?

  4. #4
    Join Date
    Nov 2008
    Posts
    8

    Default

    Yes I could pick up the cause of the exception and I'm guessing that as this is a BindException it will give me access to the user friendly messages thrown by Valang via the errors collection? If you could just confirm it will do this, I'll raise the JIRA.

  5. #5
    Join Date
    Feb 2008
    Posts
    28

    Default

    Hi,

    I had to write some custom code to extract the exact key.

    Thanks
    Venkatesh

  6. #6
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    Quote Originally Posted by JustinB View Post
    Yes I could pick up the cause of the exception and ... it will give me access to the user friendly messages
    Correct. The workaround for now is to simply write your own version of SpringValidator that does this (it's only a few lines).

Posting Permissions

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