salut à tous ,
j'utilise des beans pour faire des mise a jour dans la base de données,l'ajout et la suppression marchent bien mais la modifications me pose un probleme
voici mon code de ma liste qui contient les information sur mes champs:
La je veux lorsque je clique sur le boutton "Modifier" il m'affiche la page ou je vais faire la modification:
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 <%@ page errorPage = "/WEB-INF/erreur.jsp" import="bd.*" %> <html> <head><title>Fournisseur</title></head> <body background="D:\u.jpg"> <font face="Arial"> <h2 align="center">Fournisseur</h2> <hr> <table bgcolor="1" cellpadding="3" cellspacing="2" width="90%" align="center"> <tr bgcolor="yellow"> <th align="left"><a href="bienvenue.jsp">Liste_Fournisseur</th> <th align="right"> <a href="nouvelfournisseur.jsp">Ajouter_Fournisseur</a> </th> </table> <font face="Arial"> <p><table border="1" cellpadding="3" cellspacing="2" width="90%" align="center"> <tr bgcolor="#FF6600"> <th>Id</th> <th>Nom</th> <th>Code</th> <th>Adresse</th> <th>Tel</th> <th>Fax</th> <th>Email</th> </tr> <% ListeFournisseur listeFournisseur = new ListeFournisseur(1); int ligne = 0; while (listeFournisseur.suivant()) { %> <% String ide; ide= listeFournisseur.idFournisseur(); %> <tr bgcolor="<%= ligne++ % 2 == 0 ? "#FFFF66" : "#FFCC00" %>"> <td><%= ide %></td> <td><b><%= listeFournisseur.nom() %></b></td> <td><%= listeFournisseur.code() %></td> <td><%= listeFournisseur.adresse() %></td> <td><%= listeFournisseur.tel() %></td> <td><%= listeFournisseur.fax() %></td> <td><%= listeFournisseur.email() %></td> <td><a href="suppression.jsp?id=<%=ide %>">supprimer</td> <td><a href="modification1.jsp?id=<%= ide %>">modifier</td> </tr> <% } listeFournisseur.arrêt(); %> </table> </font> <%@page import="java.util.Date, java.text.DateFormat" %> <%! DateFormat formatDate = DateFormat.getDateInstance(DateFormat.FULL); %> <br><hr> <h4 align="right"><%= formatDate.format(new Date()) %></h4> </font> </body> </html>
La c la methode qui j'ai mis dans ma classe bean:
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 <%@ page errorPage = "/WEB-INF/erreur.jsp" import="bd.*,java.lang.Integer.*" %> <html> <head><title>Gestion Du Stock</title></head> <body background="D:\j.jpg"> <font face="Arial"> <h2 align="center">Gestion Du Stock</h2> <hr> <table bgcolor="1" cellpadding="3" cellspacing="2" width="90%" align="center"> <tr bgcolor="#FF9900"> <th align="left"><a href="bienvenue.jsp">Liste_Fournisseur</th> <th align="right"> <a href="nouvelfournisseur.jsp">Ajouter_Fournisseur</a> </th> </table> <jsp:useBean id="utilisateur" class="bd.Fournisseur"> <jsp:setProperty name="utilisateur" property="*" /> <p><table border="1" cellpadding="3" cellspacing="2" width="90%" align="center"> <tr> <td bgcolor="#FF9900" width="100"><b>Nom</b></td> <td><jsp:getProperty name="utilisateur" property="nom" /></td> </tr> <tr> <td bgcolor="#FF9900" width="100"><b>Code</b></td> <td><jsp:getProperty name="utilisateur" property="code" /></td> </tr> <tr> <td bgcolor="#FF9900" width="100"><b>Adresse</b></td> <td><jsp:getProperty name="utilisateur" property="adresse" /></td> </tr> <tr> <td bgcolor="#FF9900" width="100"><b>Tel</b></td> <td><jsp:getProperty name="utilisateur" property="tel" /></td> </tr> <tr> <td bgcolor="#FF9900" width="100"><b>Fax</b></td> <td><jsp:getProperty name="utilisateur" property="fax" /></td> </tr> <tr> <td bgcolor="#FF9900" width="100"><b>Email</b></td> <td><jsp:getProperty name="utilisateur" property="email" /></td> </tr> </table> <p> <h3 align="center"> <% Integer ide; ide =Integer.parseInt(request.getParameter("id").toString()); utilisateur.modifier(ide); %> <font color="red">Modifier votre Founisseur</font> </h3> </jsp:useBean> <%@page import="java.util.Date,java.text.DateFormat" %> <%!DateFormat formatDate = DateFormat.getDateInstance(DateFormat.FULL);%> <br><hr> <h4 align="right"><%=formatDate.format(new Date())%></h4> </font> </body> </html>
lorsque j clique sur le button "modifier" il me donne vraiment les champs et il lui donne des valeur null et je peut pas les modifier.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 public int modifier(int id){ miseAJour("update Fournisseur set nom='"+nom+"' , code='"+code+"' , adresse='"+adresse+"' , tel='"+tel+"' , fax='"+fax+"' , email='"+email+"' WHERE id='"+id+"'" ); return 1; }
SVP Que je doit mettre dans la page JSP "moddification1.jsp",pour qu'il me donne la possiblité de modifier?
Partager