IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JSF Java Discussion :

Problème passage valeur JSF ModelPanel


Sujet :

JSF Java

  1. #1
    Membre éprouvé
    Inscrit en
    Mars 2008
    Messages
    1 123
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 1 123
    Par défaut Problème passage valeur JSF ModelPanel
    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&eacute; &agrave;:</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&eacute; &agrave;:</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">
         &nbsp;</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">
         &nbsp;</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;
     
    	    }
    }

  2. #2
    Membre expérimenté Avatar de Shinzul
    Homme Profil pro
    Lecteur assidu de code source
    Inscrit en
    Janvier 2008
    Messages
    174
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Lecteur assidu de code source
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2008
    Messages : 174
    Par défaut
    Eu comme ça j'ai une réponse en lisant le code tel que tu l'as noté.

    Avec le code que tu as donné tel quel il ne set pas rech car ta méthode se nomme setrech et non pas setRech comme il est nécessaire qu'elle soit nommé selon la norme de développement Java ce qui perturbe un peu JSF.

  3. #3
    Rédacteur
    Avatar de romaintaz
    Homme Profil pro
    Java craftsman
    Inscrit en
    Juillet 2005
    Messages
    3 790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Java craftsman
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2005
    Messages : 3 790
    Par défaut
    Oui, c'est le problème. Si tu as une propriété appelée rech, alors tes méthodes d'accès doivent s'appeler getRech() et setRech(String), en respectant la casse, ce qui n'est pas le cas ici !
    Nous sommes tous semblables, alors acceptons nos différences !
    --------------------------------------------------------------
    Liens : Blog | Page DVP | Twitter
    Articles : Hudson | Sonar | Outils de builds Java Maven 3 | Play! 1 | TeamCity| CitConf 2009
    Critiques : Apache Maven

  4. #4
    Membre éprouvé
    Inscrit en
    Mars 2008
    Messages
    1 123
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 1 123
    Par défaut
    même quand j'ai respecter la Casse ça ne marche pas la valeur de rech est tujour Null

  5. #5
    Membre expérimenté Avatar de Shinzul
    Homme Profil pro
    Lecteur assidu de code source
    Inscrit en
    Janvier 2008
    Messages
    174
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Lecteur assidu de code source
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2008
    Messages : 174
    Par défaut
    Euh la valeur est toujours null a l'affichage ou lors de l'éxecution de ton getList (qui a d'ailleur le même problème de casse dans le code qui a donné )

    Si c'est a l'affichage, le reRender de ton button ne réaffiche pas la table et pour le champ affect1 devrait reRender un cran au dessus dans le DOM.

    Si c'est lors de l’exécution la seule chose que je voie c'est la casse sur le getlist ou un problème de ocnfiguration sur le nom du managedBean mais ca j'y crois vraiment moyen (mais bon c'est toujours ça de vérifié )

  6. #6
    Membre éprouvé
    Inscrit en
    Mars 2008
    Messages
    1 123
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 1 123
    Par défaut
    voici mon coe de bean après changement:
    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
     
     
    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 (getrech()=="A")
    						{
    								{
    									 list.add( new EMPLOYES("2",2,"2","2","2","2" ));
    								}
    						}
    						else
    						{
    									list.add( new EMPLOYES("43",33,"43","43","43","43" ));
    						}
     
     
    						// 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;
     
    	    }
    }
    et le code de ma page 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
     
     
     
    <%@ 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&eacute; &agrave;:</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&eacute; &agrave;:</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>
    Veuillez bien m'aider Monsieur, je suis bloquée depuis des semaines et je n'arrive pas à trouver une soution

  7. #7
    Rédacteur
    Avatar de romaintaz
    Homme Profil pro
    Java craftsman
    Inscrit en
    Juillet 2005
    Messages
    3 790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Java craftsman
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2005
    Messages : 3 790
    Par défaut
    Bonjour,

    A nouveau, ton code Java n'est pas bon. Ecrire setrech et getrech n'est pas correct ! La casse est importante !

    Ensuite, ton code ne fait pas grand chose. Que souhaites-tu faire au juste ? Dans son état actuel, une requête Ajax est bien envoyée au serveur, et la popup s'affiche, mais c'est tout. Il n'y a aucune action faite côté serveur, il n'y a pas non plus de rafraichissement d'une partie de la page côté client.
    Nous sommes tous semblables, alors acceptons nos différences !
    --------------------------------------------------------------
    Liens : Blog | Page DVP | Twitter
    Articles : Hudson | Sonar | Outils de builds Java Maven 3 | Play! 1 | TeamCity| CitConf 2009
    Critiques : Apache Maven

  8. #8
    Membre averti
    Femme Profil pro
    Inscrit en
    Juin 2011
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Juin 2011
    Messages : 20
    Par défaut
    Un petite conseil java :
    - Une classe Java commence par un majuscule, regarde : String, Object ...
    - Une constante est en générale toute en majuscule: PI, MAX ...
    - une variable ne commence pas en majuscule,

    Tu as d'abord un problème de setter et getter: getList
    Avec eclipse, pour résoudre ce problème de getter/setter, tu fais clique droit sur la variable puis source et Generate Getters ans Setters

    Tu utilises session ou request pour ton bean ?

  9. #9
    Membre éprouvé
    Inscrit en
    Mars 2008
    Messages
    1 123
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 1 123
    Par défaut
    j'utilise Session

  10. #10
    Membre averti
    Femme Profil pro
    Inscrit en
    Juin 2011
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Juin 2011
    Messages : 20
    Par défaut
    - T'as pas d'action bean associée à ton bouton de recherche. ton onClick affiche tout simplement le modal comme du javascript, je pense.
    - Tes Getters/Setters ne sont pas bons non plus.

    - Tes longs codes dans getlist doit se trouver dans la méthode sur l'action de ton bouton Rechercher.

  11. #11
    Membre éprouvé
    Inscrit en
    Mars 2008
    Messages
    1 123
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 1 123
    Par défaut
    Merci mais un petit exemple si vous pouvez me donner SVP comme ça je vais essayer à adapter mes codes à l'exemple
    SVP et merci

  12. #12
    Membre éprouvé
    Inscrit en
    Mars 2008
    Messages
    1 123
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 1 123
    Par défaut
    Aucune réponse ?????????

Discussions similaires

  1. problèmes passage JSF 2.0 et facelets
    Par storm_2000 dans le forum JSF
    Réponses: 1
    Dernier message: 25/01/2010, 10h24
  2. Problème passage de valeurs entre un Form et procédure
    Par Aizen64 dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 11/06/2007, 09h41
  3. Problème de valeur null dans un recordset
    Par Petzouille57 dans le forum Access
    Réponses: 3
    Dernier message: 19/05/2005, 11h27
  4. [JSP] Problème passage paramètre
    Par besco dans le forum Servlets/JSP
    Réponses: 5
    Dernier message: 13/09/2004, 10h15
  5. Problème passage de pointeur
    Par mick74 dans le forum MFC
    Réponses: 2
    Dernier message: 21/04/2004, 18h34

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo