3 Replies Latest reply on Jun 23, 2007 6:50 PM by jpviragine

    How can I embed label value in validation error message?

    azalea

      Hi,

      With Hibernate Validator, I want to check input fields.

      <s:validateAll>
       ............
       <tr>
       <td>
       <h:outputLable for="firstName" value="#{messages['label.firstName']}" />
       </td>
       <td>
       <s:decorate>
       <h:inputText id="firstName" value="#{person.firstName}" />
       </s:decorate>
       </td>
       </tr>
       <tr>
       <td>
       <h:outputLable for="lastName" value="#{messages['label.lastName']}" />
       </td>
       <td>
       <s:decorate>
       <h:inputText id="lastName" value="#{person.lastName}" />
       </s:decorate>
       </td>
       ............
      </s:validateAll>
      


      @Entity
      @Name("person");
      public class Person implements Serializable {
       ......
       @Pattern(regex="^[a-zA-Z]+", message="{validator.name}")
       private String firstName;
      
       @Pattern(regex="^[a-zA-Z]+", message="{validator.name}")
       private String lastName;
       ......
      }
      


      # messages.properties(for i18n)
      validator.name=<I want to embed label value of the input field here>: Input alphabet string
      
      label.firstName=first name
      label.lastName=last name
      


      When validation fails, I want to display validation error message with the label's value.
      For "firstName" input field, "first name: Input alphabet string",
      for "lastName", "last name: Input alphabet string".

      How can I implement this?

      [environment]
      JBoss Seam CVS
      JBoss AS 4.2.0.GA

      Thanks