Bonsoir à tous
om est le problème dans le code suivant:
Le bproblème c'est que la valeur de rech est toujour null, donc je ne peux pas envoyer la valeur de mapage JSF à mon modalPanel
JSF:
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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245 <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <f:view> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Gestion </title> <meta http-equiv="refresh" content="100"> <script language='javascript'> function RechNom() { Richfaces.showModalPanel('panel'); } </script> </head> <body link="#FFFFFF" ALINK="#FFFFFF" > <table border="1" cellpadding="0" cellspacing="0" style=" border-collapse: collapse" bordercolor="#FF9933" width="1133" height="628"> <tr valign="top" > <td width="898" height="579" bordercolor="#FF9933" bgcolor="#FFFFFF" valign="top" style=" width : 723px;"> <rich:tabPanel id="Article" height ="579" width="898" style=" height : 497px;"> <rich:tab name="NA" label="Nouvel article" > <h:form id="contact"> <table border="0" width="85%" cellspacing="2" cellpadding="4" style=" fontstyle:bold;"> <tr> <td width="289" align="left"><font face="Calibri"size="4" ><b> <label id="af">Affecté à:</label> </b></font></td> <td width="50%"> <h:inputText styleClass="inputText" value="#{Recherche.rech}"id="Affect1" size="75" style=" width : 403px;" /> </td> <td style=" width : 147;" align ="right"> </td> </tr> <tr> <td width="289" align="left"><font face="Calibri"size="4" ><b> <label id="af">Affecté à:</label> </b></font></td> <td width="50%"> <h:inputText styleClass="inputText" value="#{Recherche.selected}"id="Affect" size="75" style=" width : 403px;" /> </td> <td style=" width : 147;" align ="right"> <a4j:commandButton value="Recherche" reRender="Affect1" oncomplete="#{rich:component('panelEditionGestionnaire')}.show()" /> </td> </tr> <tr style=" height : 31px;"> <td></td> <td valign="top"></td> </tr> <tr> <td width="70%" valign="top"><font face="Calibri" size="4"><b></b></font></td> <td width="50%"> </td> </tr> <tr> <td width="142"> </td> <td width="405" align="right"> </td> </tr> </table> </h:form> </rich:tab> </rich:tabPanel> </td> </table> <rich:modalPanel id="panelEditionGestionnaire"> <a4j:outputPanel id="popPanel"> <h:form> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width : 821;" height="467"> <colgroup> <col width="120" style="width: 90pt"><col width="80" style="width: 60pt"> <col width="169" style="width: 127pt"><col width="108" style="width: 81pt"> </colgroup> <tr height="257" style="height: 192.75pt" valign="top"> <td colspan="4" height="355" style="border-top:1px solid #FFCC66; text-align: cleft; vertical-align: top; color: #000000; font-size: 11.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; white-space: nowrap; border-left: 1px solid #FFCC66; border-right: 1px solid #FFCC66; padding-left: 1px; padding-right: 1px; padding-top: 1px; border-bottom-width:medium" width="248"> <rich:scrollableDataTable id ="tab1" value="#{Recherche.list}" var="RECH" frozenColCount="1" first="0" rows="40" width="680px" height="396px" style="font-size:12pt;"> <rich:column width="80px" style="text-align:center;font-size:12pt;" > <f:facet name="header"><h:outputText value="TYPE" /></f:facet> <h:commandLink action="#{Recherche.takeSelection}"> <h:outputText value="#{RECH.MATRI}" /> <f:setPropertyActionListener value="#{RECH}" target="#{Recherche.selectedEM}" /> </h:commandLink> </rich:column> <rich:column width="80px" style="text-align:center;font-size:12pt;" > <f:facet name="header"><h:outputText value="TYPE" /></f:facet> <h:outputText value="#{RECH.TYPE}"style="text-align:center;" /> </rich:column> <rich:column width="80px" style="text-align:center;font-size:12pt;"> <f:facet name="header"><h:outputText value="CODE SOCIETE" /></f:facet> <h:outputText value="#{RECH.CODE_SOC}" style="text-align:center;"/> </rich:column> <rich:column width="100px" style="text-align:center;font-size:12pt;"> <f:facet name="header"><h:outputText value="NOM" /></f:facet> <h:outputText value="#{RECH.NOM}" style="text-align:center;"/> </rich:column> <rich:column width="100px" style="text-align:center;font-size:12pt;"> <f:facet name="header"><h:outputText value="PRENOM" /></f:facet> <h:outputText value="#{RECH.PRENOM}"style="text-align:center;" /> </rich:column> <rich:column width="250px" style="text-align:center;font-size:12pt;"> <f:facet name="header"><h:outputText value="FONCTION" /></f:facet> <h:outputText value="#{RECH.LIBEL}"style="text-align:center;" /> </rich:column> </rich:scrollableDataTable> </td> </tr> <tr height="8" style="height: 6.0pt"> <td height="19" style="border-left:1px solid #FFCC66; vertical-align: middle; color: #000000; font-size: 11.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; text-align: general; white-space: nowrap; padding-left: 1px; padding-right: 1px; padding-top: 1px" width="163"> </td> <td style="vertical-align: middle; color: black; font-size: 11.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; text-align: general; white-space: nowrap; border: medium none; padding-left: 1px; padding-right: 1px; padding-top: 1px" height="19" width="80"> </td> <td style="vertical-align: middle; color: black; font-size: 11.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; text-align: general; white-space: nowrap; border: medium none; padding-left: 1px; padding-right: 1px; padding-top: 1px" width="446" height="19"> </td> <td style="vertical-align: middle; color: #000000; font-size: 11.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; text-align: general; white-space: nowrap; border-right: 1px solid #FFCC66; padding-left: 1px; padding-right: 1px; padding-top: 1px; border-left-width:medium; border-top-width:medium; border-bottom-width:medium" width="135" height="19"> </td> </tr> <tr height="38" style="height: 28.5pt"> <td height="36" style="vertical-align: middle; color: #000000; font-size: 11.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; white-space: nowrap; border-left: 1px solid #FFCC66; border-top: 1px solid #FFCC66; border-bottom: 1px solid #FFCC66; padding-left: 1px; padding-right: 1px; padding-top: 1px; border-right-width:medium" width="110"> <a4j:commandButton style=" width : 96px; float:left" value="Fermer" onclick="javascript:Richfaces.hideModalPanel('panel');" /> </td> <td colspan="2" height="36" style="vertical-align: middle; color: #000000; font-size: 11.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; white-space: nowrap; border-top: 1px solid #FFCC66; border-bottom: 1px solid #FFCC66; padding-left: 1px; padding-right: 1px; padding-top: 1px; border-right-width:medium" width="297"> </td> <td style="vertical-align: middle; color: #000000; font-size: 11.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri, sans-serif; text-align: general; white-space: nowrap; border-right: 1px solid #FFCC66; border-top: 1px solid #FFCC66; border-bottom: 1px solid #FFCC66; padding-left: 1px; padding-right: 1px; padding-top: 1px; " width="135" height="36"> <h:inputText size="40" style=" width : 403px;height : 17px;" maxlength="50" id="N" /> </td> </tr> </table> </h:form> </a4j:outputPanel> <h:messages/> </rich:modalPanel> </body> </html> </f:view>
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
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 package Test; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.richfaces.component.UIScrollableDataTable; import org.richfaces.model.selection.SimpleSelection; import Test.BDD; import java.sql.Connection; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; public class Recherche { private SimpleSelection selection = new SimpleSelection(); private List<EMPLOYES> list=null; private EMPLOYES SelectedEM; private UIScrollableDataTable table; private String rech, NOM, Selected,A; private int MAT ; public void setrech(String rech) { this.rech=rech; } public String getrech() { return rech; } public List<EMPLOYES> getlist() { if(list==null) { Connection con= new BDD().getCon(); String SqlStr=""; Statement stmt; list = new ArrayList<EMPLOYES>(); //SqlStr = " SELECT NOM FROM dc_demandeurex WHERE CODE_SOC='"++"' ";//OR UPPER(DC_DEMANDEUREX.PRENOM) LIKE '%"+ MO.toUpperCase() +"%'";//UNION" ; SqlStr="SELECT NOM FROM dc_demandeurex WHERE CODE_SOC='"+rech+"'"; // SqlStr =SqlStr+ " select CODE_SOC, MATRI, NOM, PRENOM, LIBEL,'INTERNE' as INTERNE from DC_EMPLOYES WHERE UPPER(DC_EMPLOYES.NOM) LIKE '%"+ MO.toUpperCase() +"%'OR UPPER(DC_EMPLOYES.PRENOM) LIKE '%"+ MO.toUpperCase() +"%' ORDER BY TYPE DESC, CODE_SOC, MATRI, NOM, PRENOM "; if (rech!=null) { try { stmt = con.createStatement(); ResultSet RS = stmt.executeQuery(SqlStr); if (RS.next()) { //while(RS.next()) { // list.add( new EMPLOYES(RS.getString("CODE_SOC"),RS.getInt("MATRI"),RS.getString("NOM"),RS.getString("PRENOM"),RS.getString("LIBEL"),RS.getString("TYPE") )); list.add( new EMPLOYES("2",2,"2","2","2","2" )); } } else { list.add( new EMPLOYES("44",44,"44","44","44","44" )); } RS.close(); con.close(); } catch (SQLException e) { e.printStackTrace(); } } else { list.add( new EMPLOYES("5",5,"55","555","5","55" )); } } return list; } public SimpleSelection getSelection() { return selection; } public void setSelection(SimpleSelection selection) { this .selection = selection; } //************************************************* //******************************************** public String getSelected() { return Selected; } public void setSelected(String Selected) { this .Selected = Selected; } //********************************** public String getNom() { return NOM; } public void setNOM(String NOM) { this .NOM = NOM; } //******************************** public int getMAT() { return MAT; } public void setMAT(int MAT) { this .MAT = MAT; } //********************************* public String takeSelection() { MAT=getSelectedEM().getMATRI(); NOM=getSelectedEM().getNOM(); Selected= getSelectedEM().getCODE_SOC(); if (getSelection().isSelectAll()){ }else{ Iterator<Object> iterator = getSelection().getKeys(); while (iterator.hasNext()){ Object key = iterator.next(); table.setRowKey(key); // getSelectedEM().getNOM();//(table.getRowData()); } } System.out.print("hsss"+rech+"sssg"); return null; } //****************************************** public EMPLOYES getSelectedEM() { return SelectedEM; } public void setSelectedEM( EMPLOYES SelectedEM) { this.SelectedEM = SelectedEM; } }
Partager