Bonjour tous les developpeurs !
voila mon problème, je dois valider un champ nommé nom.
je dois tester est ce que le champ est vide ou non !
voila le code
Voila la page jsp :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 public class userbean { String nom; public userbean(){} public void validateNom(FacesContext context,UIComponent toValidate,Object value) throws ValidatorException { String e = (String) value; if(e.equals("")) throw new ValidatorException(new FacesMessage("invalide Nom")); } public String getNom() { return Nom; } public void setNom(String Nom) { this.Nom= Nom; } }
Code:
1
2
3
4
5
6
7
8 <td><h:outputText value="email " /></td> <td><h:inputText value="#{userbean.nom}" id="nom" required="true" validator="#{userbean.validatNom}"/></td> <td><h:message for="nom"/></td> </tr> <tr> <td><h:commandButton value="valider" action="register"/></td>
Lorsque je teste il me donner le message par défaut ! mais moi je désire qu'il me donne mon message !
Merci d'avance