Announcement Announcement Module
Collapse
No announcement yet.
Getting error message from ValidationException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


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

      Comment


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

        Comment


        • #5
          Hi,

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

          Thanks
          Venkatesh

          Comment


          • #6
            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).

            Comment

            Working...
            X