Bonjour, jusqu'à maintenant j'ai pu créer mon clientsForm, et mes pages Clients.jsp, ajoutClient.jsp, editClient.jsp, tout marche tres tres bien mais lorsque j'ai voulu controler les données saisie j'ai trouvé enormement de problème il me dit que :struts-config.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 message No input attribute for mapping path /gestClient description Le serveur a rencontré une erreur interne (No input attribute for mapping path /gestClient) qui l'a empêché de satisfaire la requête.
ClientsForm :
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
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <form-beans> <form-bean name="cfc" type="presentation.str.ClientsForm"/> </form-beans> <global-forwards> <forward name="VueClient" path="client.page"/> <forward name="addClient" path="ajoutclient.page"/> <forward name="editClient" path="editclient.page"/> </global-forwards> <action-mappings> <action path="/gestClient" name="cfc" type="presentation.str.ClientsAction" scope="session" validate="true"> </action> </action-mappings> <message-resources parameter="ApplicationResources"/> <!-- Tiles Configuration --> <plug-in className="org.apache.struts.tiles.TilesPlugin"> <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/> </plug-in> </struts-config>
Clients.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
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142 package presentation.str; import java.util.List; import java.util.Vector; import javax.servlet.http.HttpServletRequest; import ma.corporate.planning.metier.Client; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; public class ClientsForm extends ActionForm { private String motcle; private List<Client> clients = new Vector<Client>(); private String action = ""; private int idClient; private Client client = new Client(); private String raisonSocial; private String adresse; private String tel; private String email; private String ville; private String pays; public String getMotcle() { return motcle; } public void setMotcle(String motcle) { this.motcle = motcle; } public List<Client> getClients() { return clients; } public void setClients(List<Client> clients) { this.clients = clients; } public String getAction() { return action; } public void setAction(String action) { this.action = action; } public int getIdClient() { return idClient; } public void setIdClient(int idClient) { this.idClient = idClient; } public Client getClient() { return client; } public void setClient(Client client) { this.client = client; } public String getRaisonSocial() { return raisonSocial; } public void setRaisonSocial(String raisonSocial) { this.raisonSocial = raisonSocial; } public String getAdresse() { return adresse; } public void setAdresse(String adresse) { this.adresse = adresse; } public String getTel() { return tel; } public void setTel(String tel) { this.tel = tel; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getVille() { return ville; } public void setVille(String ville) { this.ville = ville; } public String getPays() { return pays; } public void setPays(String pays) { this.pays = pays; } public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) { ActionErrors errors = new ActionErrors(); if ((raisonSocial == null) || (raisonSocial.length() < 1)) errors.add("raisonSocial", new ActionError("error.raisonSocial.vide")); if ((adresse == null) || (adresse.length() < 1)) errors.add("adresse", new ActionError("error.adresse.vide")); if ((tel == null) ){ errors.add("tel", new ActionError("error.tel.vide")); } else { if (!tel.matches("^\\s*\\d+\\s*$") || (tel.length() < 9)) { errors.add("telinvalide", new ActionError("error.tel.invalide")); } } if ((email == null) || (email.length() < 1)){ errors.add("email", new ActionError("error.email.vide")); } else { if (!email.matches(".+@.+\\.[a-z]+")) { errors.add("emailinvalide", new ActionError("error.email.invalide")); } } if ((ville == null) || (ville.length() < 1)){ errors.add("ville", new ActionError("error.ville.vide")); }//(!ville.matches("[^0-9]*")) else { if (!ville.matches("[^0-9]*")) { errors.add("villeinvalide", new ActionError("error.ville.invalide")); } } if ((pays == null) || (pays.length() < 1)){ errors.add("pays", new ActionError("error.pays.vide")); } else { if (!pays.matches("[^0-9]*")) { errors.add("paysinvalide", new ActionError("error.pays.invalide")); } } return errors; } }je commence par clients.jsp, j'ajoute et je reviens a clients.jsp, lorsque je commente la méthode validate et je met :
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
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%> <%@ page import="ma.corporate.planning.metier.*"%> <html:form action="gestClient.do"> <p> </p> <p> <span class="label">Client :</span> <html:text property="motcle" value=""></html:text> <html:submit value="Chercher" property="action" styleClass="search"></html:submit> <html:submit value="Ajouter" property="action" styleClass="add"></html:submit> </p> <br> <p> <table border="1" width="90%" bordercolor="294C9E" align="center"> <tr class="submit"> <th>Raison Social</th><th>Adresse</th><th>Email</th><th>Tel</th><th>Ville</th><th colspan="2"> </th> </tr> <%int nb=0; %> <logic:iterate id="cli" name="cfc" property="clients" type="Client"> <tr <%if(nb==0){%> bgcolor="EAEEF1" <% nb=1;} else {%> bgcolor="A2BAD4" <% nb=0;} %>> <td><bean:write name="cli" property="raisonSocial"/></td> <td><bean:write name="cli" property="adresse"/></td> <td><bean:write name="cli" property="email"/></td> <td><bean:write name="cli" property="tel"/></td> <td><bean:write name="cli" property="ville"/></td> <td bgcolor="FFFFFF" align="center"><a href="gestClient.do?action=Editer&idClient=<%=cli.getIdClient() %>"> <img src="vues/images/modifier.png" border="0"></a></td> <td bgcolor="FFFFFF" align="center"><a href="javascript:confirmation('gestClient.do?action=Supprimer&idClient=<%=cli.getIdClient() %>')"> <img src="vues/images/supprimer.jpg" border="0"></a></td> </tr> </logic:iterate> </table> </p> </html:form>
ca marche mais sans validation, please veuillez m'aider !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 <action path="/gestClient" name="cfc" type="presentation.str.ClientsAction" scope="session" />
Partager