[jboss-user] [JBoss Seam] - How can I embed label value in validation error message?

azalea do-not-reply at jboss.com
Sat Jun 2 20:26:55 EDT 2007


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


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050717#4050717

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050717



More information about the jboss-user mailing list