السلام عليكم ورحمة الله
هذه الكلاس التي اقوم من خلالها بملا جدول
package Test;
import java.math.BigDecimal;
import java.sql.Connection;
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.model.ScrollableTableDataModel.SimpleRowKey;
import org.richfaces.model.selection.Selection;
import org.richfaces.model.selection.SimpleSelection;
public class Recherche {
private Selection selection = new SimpleSelection();
private ArrayList<EMPLOYES> selectedEM= new ArrayList<EMPLOYES>();
private ResultSet RS;
private String Selected;
private static List<EMPLOYES> list = null;
public List<EMPLOYES> getlist() {
synchronized (this ) {
Connection con = new BDD().getCon();
try {
list = new ArrayList<EMPLOYES>();
String SqlStr = " select CODE_SOC, MATRI, NOM, PRENOM, FONCTION as LIBEL,'EXTERNE' as TYPE from DC_DEMANDEUREX";// UNION" ;
// SqlStr =SqlStr+ " select CODE_SOC, MATRI, NOM, PRENOM, LIBEL,'INTERNE' as INTERNE from DC_EMPLOYES ORDER BY TYPE DESC, CODE_SOC, MATRI, NOM, PRENOM ";
Statement stmt= con.createStatement();
RS = stmt.executeQuery(SqlStr);
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") ));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return list;
}
public String getSelected()
{
return Selected;
}
public void setSelected(String Selected) {
Selected= getSelectedEM().get(0).getCODE_SOC();
}
public Selection getSelection() {
return selection;
}
public void setSelection(Selection selection) {
this .selection = selection;
System.out.println( selection.size());
System.out.println( getSelectedEM().size());
}
public String takeSelection() {
getSelectedEM().clear();
Iterator<Object> iterator = getSelection().getKeys();
while (iterator.hasNext()) {
SimpleRowKey key = (SimpleRowKey) iterator.next();
getSelectedEM().add(getlist().get(key.intValue()));
}
return null;
}
public ArrayList<EMPLOYES> getSelectedEM() {
return selectedEM;
}
public void setSelectedEM(
ArrayList<EMPLOYES> selectedEM) {
this.selectedEM = selectedEM;
}
}وكود الجدول هو
<%@ 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="NouvelArticle">
<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" id="Affect" size="75" style=" width : 403px;" disabled="true"/>
</td>
<td style=" width : 147;" align ="right">
<a4j:commandButton value="Recherche" onclick="javascript:RechNom()" />
</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>
<rich:modalPanel id="panel" width="700" height="498">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Sélection demandeur"></h:outputText>
</h:panelGroup>
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
</h:panelGroup>
</f:facet>
<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">
<a4j:commandButton value="Show Current Selection" reRender="Affect"
oncomplete="javascript:Richfaces.showModalPanel('panel');"/>
<rich:scrollableDataTable var="RECH" value="#{Recherche.list}" selection="#{Recherche.selection}"
frozenColCount="1"
first="0"
rows="40"
width="680px"
height="396px" style="font-size:12pt;">
<rich:column sortBy="#{RECH.TYPE}" 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 sortBy="#{RECH.MATRI}" width="70px" style="text-align:center;font-size:12pt;">
<f:facet name="header"><h:outputText value="MATRICULE" /></f:facet>
<h:outputText value="#{RECH.MATRI}" style="text-align:center;"/>
</rich:column>
<rich:column sortBy="#{RECH.CODE_SOC}" 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 sortBy="#{RECH.NOM}" 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 sortBy="#{RECH.PRENOM}" 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 sortBy="#{RECH.LIBEL}" 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:commandButton style=" width : 96px; float:right" value="Valider" id="Rech3" />
</td>
</tr>
</table>
</rich:modalPanel>
</h:form>
</rich:tab>
</rich:tabPanel>
</td>
</table>
</body>
</html>
</f:view>المشكل هو لماذا دائما لما اريد الحصور على عدد الاسطر المحددة هو 0؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟
حتى لو قمت بتحديد سطر النتيجة دائما 0