je veux travailler sur une validation côté client avec le puging validator pour cela j'ai vu certains exemples utilisant ce dernière ensuite j'essaie faire un exemlpe pour le comprendre mais ca marche pas.
Voici tous ce que concerne mon exemple:

struts-config.xml:

Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
          "http://struts.apache.org/dtds/struts-config_1_3.dtd">
 
<struts-config>
<form-beans>
		<form-bean name="client" type="struts.beans.ClientBean"/>
</form-beans>
<action-mappings>
		<action path="/afficher"
		    scope="session"
			input="/page1.jsp" 
			name="client"   
			type="struts.actions.ClientAction"
			validate="true">
			<forward name="ok" path="/page2.jsp"/>
		</action>
</action-mappings>
<message-resources parameter="MessageResources" />
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
page jsp:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
<html:javascript formName="monForm"/>
</head>
<body>
<html:form action="afficher"  onsubmit="return validateMonForm(this);">
<table>
<tr>
<td>Nom :</td>
<td><input type="text" name="nom"></td>
<td><input type="submit" value="Afficher"></td>
</tr>
</table>
</html:form>
</body>
</html>
mon ActionForm :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
public class ClientBean extends ValidatorForm {
private String nom;
 
public ClientBean() {
	super();
}
public String getNom() {
	return nom;
}
public void setNom(String nom) {
	this.nom = nom;
}
}
validation.xml

Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC
         "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN"
         "http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">
<form-validation>
   <formset>             
      <form name="monForm">
         <field property="nom" depends="required">
            <msg name="required" key="error.nom.obligatoire"/>
         </field>   
      </form>        
   </formset>   
</form-validation>
le fichier de messages:

errors.header=<ul>
errors.prefix=<li style="color:red">
errors.suffix=</li>
errors.footer=</ul>
error.nom.obligatoire=Le champ nom est obligatoire
errors.required={0} est obligatoire.
errors.invalid={0} est invalide.
errors.maxlength={0} ne peut pas avoir plus de 8 caractère(s).
errors.minlength={0} ne peut pas avoir moins de {1} caractère(s).
errors.range={0} n'est pas dans l'intervalle de {1} à {2}.
errors.byte={0} doit être un nombre du type byte.
errors.date={0} incorrecte.
errors.double={0} doit être un nombre du type double.
errors.float={0} doit être un nombre du type float.
errors.integer={0} doit être un nombre du type Integer.
errors.long={0} doit être un nombre du type long.
errors.short={0} doit être un nombre du type short.
errors.creditcard={0} n'est pas un numéro de carte de crédit valide.
errors.email={0} n'est pas une adresse e-mail valide.
et pour le fichier validator-rules.xml j'utilise le fichier fourni dans la destribution de Strus

ce que je pourrais:
une fois je clique sur le bouton submit sans saisir aucune valeur alors que struts m'affiche un message d'erreur.

metci d'avance.