الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكل في تحديد اسطر

بدأه lovely_ned في 6 يوليو 2011 · 6 رد · 1,005 مشاهدة · في JavaEE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله

هذه الكلاس التي اقوم من خلالها بملا جدول

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

#2

لا توجد اجابة؟؟؟؟؟؟؟؟؟؟؟

#3

No answer??????????????????

#4

حياك أخي ..

اقتباس

المشكل هو لماذا دائما لما اريد الحصور على عدد الاسطر المحددة هو 0؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟

حتى لو قمت بتحديد سطر النتيجة دائما 0

لم أفهم سؤالك.. هلّا وضحت أكثر

عفواً أحبتي انقطاعي بسبب الدراسة دعواتكم بالتوفيق..

{ لا ينال العلم مستحٍ ولا مستكبر }

#5

رمضان كريم للجميع

شكرا اخي على الرد

كود الصفحة هو

<%@ 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" >


<h:form>
   <table border="0" width="85%" cellspacing="2" cellpadding="4"  style=" fontstyle:bold;"> 
 			 <tr> 
            <td width="200" align="left" style=" width : 81px;"><font face="Calibri"size="4" ><b>
			<label id="af">Affecté à:</label>
			</b></font></td> 

			 <td width="100" style=" width : 80px;">
			  <h:inputText  styleClass="inputText" value="#{Recherche11.rech}"id="Affect" size="75"  style=" width : 197px;" />

            </td> 

			 <td style=" width : 395px;" align ="left"> 



			 <a4j:commandButton value="Recherche112"  reRender="Affect" 
			  onclick="javascript:RechNom()" />

			 </td> 
         	   </tr>  
	       	 </table>

</h:form>






<rich:modalPanel id="panel" width="680"
            height="796">
		<f:facet name="header">
			<h:outputText value="Modifier un gestionnaire" />
		</f:facet>

<a4j:outputPanel id="panel1" >
<h:form>
	<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:
 collapse; width : 821;" height="467">

   <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="tab" value="#{Recherche11.list}" var="RECH" sortMode="single"selection="#{Recherche11.selection}"

            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:outputText  value="#{RECH.TYPE}"style="text-align:center;" />
             </rich:column> 

           <rich:column 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 width="70px" style="text-align:center;font-size:12pt;">
             <f:facet name="header"><h:outputText value="MATRICULE" /></f:facet>
             <h:outputText value="#{RECH.CODE_SOC}" style="text-align:center;"/>
           </rich:column>


</rich:scrollableDataTable >
</td>
   </tr>
     <tr> 
            <td width="200" align="left" style=" width : 81px;"><font face="Calibri"size="4" ><b>
			<label id="af">Affecté à:</label>
			</b></font></td> 

			 <td width="100" style=" width : 80px;">
			  <h:inputText  styleClass="inputText" value="#{Recherche11.Rech}"id="Affect" size="75"  style=" width : 197px;" />

            </td> 

			 <td style=" width : 395px;" align ="left"> 



			 <a4j:commandButton value="Recherche11"  reRender="tab" action="#{Recherche11.getlist1}"
			   />

			 </td> 
         	   </tr>  
 </table>
</h:form>
</a4j:outputPanel>

</rich:modalPanel>















</body>
</html>
</f:view>

كود الكلاس هو

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 Recherche11 {
	private SimpleSelection selection = new SimpleSelection();
	private List<EMPLOYES> list=null;
	private EMPLOYES SelectedEM; 
	private UIScrollableDataTable table;
	private String Rech, NOM, Selected;
	private int MAT ;



	  public void setRech(String Rech)
		{ 
			this.Rech=Rech; 
		} 
		public String  getRech()
		{ 
			return Rech;
		}

  public List<EMPLOYES> getlist() {


			Connection con= new BDD().getCon();
			String SqlStr="";
			Statement stmt;
		  list = new ArrayList<EMPLOYES>();
				//try
				{
						//SqlStr="SELECT NOM FROM dc_demandeurex WHERE NOM='"+ Rech +"'";
						//stmt = con.createStatement();
						//ResultSet RS = stmt.executeQuery(SqlStr);

						// if (RS.next())
					 if (rech!=null)
						{
								{
									 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();
					//}






	    return  list;
   }




  public String getlist1() {


		Connection con= new BDD().getCon();
		String SqlStr="";
		Statement stmt;
	  list = new ArrayList<EMPLOYES>();
			//try
			{
					//SqlStr="SELECT NOM FROM dc_demandeurex WHERE NOM='"+ Rech +"'";
					//stmt = con.createStatement();
					//ResultSet RS = stmt.executeQuery(SqlStr);

					// if (RS.next())
				 if (getRech()!=null)
					{
					 list.add( new EMPLOYES("5A",5,"5A","5","5","5" ));


					}
					else 

					{
								list.add( new EMPLOYES("3A",3,"3A","3","3","3" ));
					}


					// RS.close();
						//con.close();


				} 
			//catch (SQLException e) {

				//	e.printStackTrace();
				//}






  return  "";
}


	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;

	    }
}

المشكلة في الكود التالي هو

اريد لما تظهر modalpanel يظهر فيها الجدول فارغ ثم في modalpanel عندي زر يقوم بعملية البحث في قاعدة البيانات ومن ثم يتم ملا الجدول

شكرا على مساعدتكم وجزاكم الله خيرا في هذا الشهر الكريم

#6

من فضلكم الايوجد من يساعدني؟؟؟؟؟؟؟؟؟؟؟

#7

لم أفهم شئ ...

ماذا تريدي بالتحديد ؟؟

مواضيع مشابهة