Announcement Announcement Module
Collapse
No announcement yet.
How to use parameters in Hibernate validation messages? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use parameters in Hibernate validation messages?

    I uses Hibernate validation in a bean and defines the validation messages in a properties file. Is there any way to use parameters in the message? So I can use one validation message for all the fields that are required? Now each required field has a validation message, and it is really tedious. Thanks.

    Code:
    	@NotBlank(message="{form.sampleId.NotBlank}")
    	private String sampleId;
    Code:
    form.sampleId.NotBlank=Sample ID is a required field.

  • #2
    There is a previous thread that talks about using parameters in a validation message. The thread is pretty long, but I think covers what you are asking: http://forum.springsource.org/showth...Error-Messages

    There is also a Jira issue regarding validation annotation ordering that was fixed in Spring 3.0.4. The issue is a good source of info on handling these parameters: https://jira.springsource.org/browse/SPR-6730.

    Comment

    Working...
    X