Bonjour , j'ai un petit blem j'utilise hibernate et JSF alors je dois afficher une liste des employés a partir d'une base de donnée aprés dans cette liste je dois selectionné un seul employé pour le modifier ou le supprimer par exemple le probléme c'est qu'on j'utilise un selectoneradio dans le datatable il me permet de selectionner plusieurs boutton radio parcequ'il cree dans chaque fois un nouveau groupe selectoneradio méme si je lui donne le meme Id voila le managedbean employe :
*****************************************************
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 package p1; import java.util.ArrayList; import java.util.List; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; public class employe { private int code; private String nom; private String prenom; private String login; public String getNom() { return nom; } public void setNom(String nom) { this.nom= nom; } public String getPrenom() { return prenom; } public void setPrenom(String prenom) { this.prenom= prenom; } public int getCode() { return code; } public void setCode(int code) { this.code = code; } public String getLogin() { return login; } public void setLogin(String login) { this.login = login; } static List listeEmp = new ArrayList(); public List getlisteEmploye() { Transaction tx = null; Session session = InitSessionFactory.getInstance().getCurrentSession(); try { tx = session.beginTransaction(); Query query = session.createQuery("from employe"); listeEmp= query.list(); } catch (HibernateException e) { e.printStackTrace(); if (tx != null && tx.isActive()) tx.rollback(); } return(listeEmp); } }
*****************************************************
et voila la page JSF que j'utilise :
******************************************************
*******************************************************
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 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Liste employe </title> </head> <body> <f:view> <h:dataTable value="#{employe.listeEmploye}" var="emp"> <h:column> <f:facet name="header"> <f:verbatim>code</f:verbatim></f:facet> <h:outputText value="#{emp.code}"></h:outputText> </h:column> <h:column> <f:facet name="header"> <f:verbatim>nom</f:verbatim></f:facet> <h:outputText value="#{emp.nom}"></h:outputText> </h:column> <h:column> <f:facet name="header"> <f:verbatim>prenom</f:verbatim></f:facet> <h:outputText value="#{emp.prenom}"></h:outputText> </h:column> <h:column> <f:facet name="header"> <f:verbatim>login</f:verbatim></f:facet> <h:outputText value="#{emp.login}"></h:outputText> </h:column> <h:column> <h:selectOneRadio layout="pageDirection" > <f:selectItem itemValue="#{emp.code}" /> </h:selectOneRadio> </h:column> </h:dataTable><br> </f:view> </body> </html>
Je crois que ma question est claire ?????????????????????????? merçi pour la réponse
Partager