Salut je débute dans le développement web java et je suis entrain de développer une petite application de gestion des employes avec JSF HIBERNATE SPRING et une SGBD PostgreSql.
dans mon application j'ai un champs SelectOneMenu qui recupere tous les id dans la base
moi je veux recuperer les valeur de ce champs pour pouvoir remplir tous les autre champs avec une methode getEmployesById je vous envoie le code et merci pour votre aide
Code java : 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
 
package com.sungard.beans;
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
 
import javax.faces.model.SelectItem;
 
import antlr.collections.List;
 
import com.sungard.persistence.Employe;
import com.sungard.service.IEmployeService;
 
public class EmployeBean {
 
	//private String empId;
	Employe employe;
             private int id;
	private String nom;
	private String prenom;
	private Date date_embauche;
	private float salaire;
	private String fonction;
	private IEmployeService empServ;
	public ArrayList<Employe> employes;
	public ArrayList<SelectItem> listIds;
	public EmployeBean() {
	employe=new Employe();
	/*listIds=new ArrayList<SelectItem>();
	employes = new ArrayList<Employe>();
	employes= empServ.findEmployes();*/
	}
 
 
 
	public ArrayList<SelectItem> getListIds() {
		System.out.println("employes list size: "+getEmployes().size());
		if(listIds==null)
			listIds=new ArrayList<SelectItem>();
		for (Employe emp : getEmployes()) {
			SelectItem selectItem=new SelectItem();
			selectItem.setLabel(String.valueOf(emp.getId()));
			selectItem.setValue(String.valueOf(emp.getId()));
			listIds.add(selectItem);
		}
		System.out.println(listIds);
		return listIds; 
 
	}
 
 
 
	public void setListIds(ArrayList<SelectItem> listIds) {
		this.listIds = listIds;
 
 
	}
	public ArrayList<Employe> getEmployes() {
		if(employes==null)
			employes = empServ.findEmployes();
		return employes;
	}
 
 
 
	public void setEmployes(ArrayList<Employe> employes) {
		this.employes = employes;
	}
 
 
	public String addEmployeAction(){
		try{
 
			employe.setNom(nom);
			System.out.println(nom);
 
			employe.setPrenom(prenom);
			System.out.println(prenom);
 
			employe.setDate_embauche(date_embauche);
			System.out.println(date_embauche);
 
			employe.setSalaire(salaire);
			System.out.println(salaire);
 
			employe.setFonction(fonction);
			System.out.println(fonction);
 
			this.empServ.addEmploye(employe);
			return "success";
		}catch(Exception e){
			e.printStackTrace();
			return "failure";
		}		
	}
	public String deleteEmployeAction(){
		try{
			this.empServ.deleteEmploye(this.employe);
			return "success";
		}catch(Exception e){
			e.printStackTrace();
			return "failure";
		}
	}
	public String updateEmployeAction(){
		try{
			employe.setNom(nom);
			System.out.println(nom);
 
			employe.setPrenom(prenom);
			System.out.println(prenom);
 
			employe.setDate_embauche(date_embauche);
			System.out.println(date_embauche);
 
			employe.setSalaire(salaire);
			System.out.println(salaire);
 
			employe.setFonction(fonction);
			System.out.println(fonction);
			this.empServ.deleteEmploye(this.employe);
			return "success";
		}catch(Exception e){
			e.printStackTrace();
			return "failure";
		}
	}
	public void findAction(int id){
		employe=this.empServ.getEmployeById(id);
		this.nom=employe.getNom();
		this.prenom=employe.getPrenom();
		this.date_embauche=employe.getDate_embauche();
		this.salaire=employe.getSalaire();
		this.fonction=employe.getFonction();
 
	}
 
	public void setEmpServ(IEmployeService empServ) {
		this.empServ = empServ;
	}
 
	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 Date getDate_embauche() {
		return date_embauche;
	}
	public void setDate_embauche(Date date_embauche) {
		this.date_embauche = date_embauche;
	}
	public float getSalaire() {
		return salaire;
	}
	public void setSalaire(float salaire) {
		this.salaire = salaire;
	}
	public String getFonction() {
		return fonction;
	}
	public void setFonction(String fonction) {
		this.fonction = fonction;
	}
	public IEmployeService getEmpServ() {
		return empServ;
	}
 
	public int getId() {
		return id;
	}
 
 
 
	public void setId(int id) {
		this.id = id;
	}
 
 
 
}
/*public void setEmpId(String empId) {
		this.empId = empId;
		if(empId!=null && !empId.equals("")){
			Integer id=new Integer(empId);
			try{
				if(empServ!=null){
					empServ.getEmployeById(id);
				}
			}
				catch(Exception e){
					e.printStackTrace();
				}
 
			}
		}*/
Code html : 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
 
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%><%@taglib
        uri="http://java.sun.com/jsf/html" prefix="h"%><%@ page language="java"
        contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!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>Insert title here</title>
</head>
<body>
 
<f:view>
	<h:form style="height: 40px">
		<h1>Bienvenu dans la recherche des employés</h1>
	</h:form>
 
	<h:panelGrid border="1" columns="3" style="height: 22px; width: 516px">
 
		<h:form>
			<h:panelGrid border="1" columns="2"
				style="width: 516px; height: 241px">
				<h:outputText value="ID"></h:outputText>
 
				<h:selectOneMenu style="width: 246px; height: 27px" id="ncin"
					value="#{employeBean.id}">
					<f:selectItems value="#{employeBean.listIds}" />
 
				</h:selectOneMenu>
 
				<h:outputText value="Nom"></h:outputText>
				<h:inputText id="nom" value="#{employeBean.nom}" style="width: 246px; height: 24px"></h:inputText>
				<h:outputText value="Prenom"></h:outputText>
				<h:inputText id="prenom" value="#{employeBean.prenom}" style="width: 245px; height: 29px"></h:inputText>
				<h:outputText value="Date d'embauche"></h:outputText>
				<h:inputText id="date" value="#{employeBean.date_embauche}" style="width: 246px; height: 29px"><f:convertDateTime type="date" pattern="dd/MM/yyyy"/></h:inputText>
				<h:outputText value="Salaire"></h:outputText>
				<h:inputText id="salaire" value="#{employeBean.salaire}" style="width: 247px; height: 29px"></h:inputText>
				<h:outputText value="Fonction"></h:outputText>
				<h:inputText id="fonction" value="#{employeBean.fonction}" style="width: 247px; height: 29px"></h:inputText>
 
			</h:panelGrid>
 
			<h:commandButton value="FIND" action="#{employeBean.findAction}" style="width: 145px" />
			<h:commandButton value="UPDATE" action="#{employeBean.updateEmployeAction}" style="width: 145px" />
			<h:commandButton value="DELETE" action="#{employeBean.deleteEmployeAction}" style="width: 145px" />
 
 
 
		</h:form>
	</h:panelGrid>
 
 
 
 
 
</f:view>
</body>
</html>
en fait pour la valeur c'est bon j'ai pu la recuperer
mais quand je clique sur find rien ne se passe
Merci de m'aider