bonsoir je suis débutant et je travail sur un projet de fin etude avec struts ma question est comment puis-je selectionner une ligne avec un bouton radio d'une liste et recuperer la selection sur un formulaire pour faire une modification.
j'ai une class ListeSocieteAction
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 public class ListeSocieteAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, SQLException { InscriptionSocieteForm inscritForm = (InscriptionSocieteForm) form; Statement st = null; ResultSet rs = null; String requête = null; ArrayList list= new ArrayList(); // obtenir une connexion Connection cnx = null; try { Class.forName("org.postgresql.Driver"); cnx = DriverManager.getConnection("jdbc:postgresql:xxxx","xxxx","xxxxx"); System.out.println("Connexion à la base \"xxxxx\" réussie"); } catch (Exception e) { System.out.println("La connexion est impossible<br>"); System.out.println(e.toString()); } // préparer la requête SQL requête = "select n_siret,nom_societe,nom_gerant,mot_passe,n_voi,qtq,voi,complement,commune,ville,telephone from societe order by n_siret"; // l'exécuter st = cnx.createStatement(); rs = st.executeQuery(requête); // exploiter les résultats while (rs.next()) { // enregistrer la ligne courante Societe alSociete = new Societe(); alSociete.setNSiret(rs.getString("n_siret")); alSociete.setNomSociete(rs.getString("nom_societe")); alSociete.setNomGerant(rs.getString("nom_gerant")); alSociete.setMotPasse(rs.getString("mot_passe")); alSociete.setNVoi(rs.getString("n_voi")); alSociete.setQtq(rs.getString("qtq")); alSociete.setVoi(rs.getString("voi")); alSociete.setComplement(rs.getString("complement")); alSociete.setCommune(rs.getString("commune")); alSociete.setVille(rs.getString("ville")); alSociete.setTelephone(rs.getString("telephone")); list.add(alSociete); } // libérer les ressources rs.close(); st.close(); // on libère la connexion try { cnx.close(); } catch (Exception ignored) { } // c'est bon request.setAttribute("listSociete", list); return mapping.findForward("afficherListeSociete"); //execute } } //classe
ma liste 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 <%@ 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" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h3>Liste des Societés</h3><br><br> <table border="1" align="center" bordercolor="#000000"> <thead> <tr> <th><div align="center">Selection</div></th> <th><div align="center">Numéro de Siret</div></th> <th><div align="center">Nom de la Societé</div></th> <th><div align="center">Nom du Gérant</div></th> <th><div align="center">Mot de passe</div></th> <th><div align="center">Numéro de voi</div></th> <th><div align="center">Qtq</div></th> <th><div align="center">Voi</div></th> <th><div align="center">Complément</div></th> <th><div align="center">Commune</div></th> <th><div align="center">Ville</div></th> <th><div align="center">Téléphone</div></th> </tr> </thead> <tbody> <logic:iterate name="listSociete" id="alSociete"> <tr> <td><div align="center"> <td><input type="radio" name="radio" id="radio" value="radio" /></div></td> <td><div align="center"> <bean:write name="alSociete" property="NSiret"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="nomSociete"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="nomGerant"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="motPasse"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="NVoi"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="qtq"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="voi"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="complement"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="commune"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="ville"/> </div></td> <td><div align="center"> <bean:write name="alSociete" property="telephone"/> </div></td> </logic:iterate> </tbody> </table> <input type="button" name="modifier" value="modifier"><br> </body> </html>
Partager