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 :

[RichFaces] Rafraîchir table après suppression d'un row


Sujet :

JSF Java

  1. #1
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut [RichFaces] Rafraîchir table après suppression d'un row
    Bonjour les jeunes

    j'utilise richfaces 4.1.0 et jsf 2.0

    J'ai une table et sur chaque ligne, j'ai un bouton de suppression. Dès que je clique sur supprimer la ligne correspondante est supprimé de la base de données , mais la table ne se rafraichit pas . Elle affiche toujours l'ancien enregistrement supprimé , il faut que j'actualise la page pour qu'il soit effacer définitivement du datatable veuillez m'aider s'il vous plait à résoudre ce problème ?


    voici une partie du code de la page administration.xhtml

    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
     
    <h:form id="form">
     
     
            <h:panelGrid columnClasses="acent">
     
                <rich:dataScroller for="table" maxPages="4" fastStep="3"/>
     
                <rich:dataTable value="#{show.lista}" var="personne" id="table" rows="5">
     
     
     
         <rich:column>
                        <f:facet name="header">
                            <h:outputText value="CIN " />
                        </f:facet>
                        <h:outputText value="#{personne.cin}"/>
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Nom" />
                        </f:facet>
                        <h:outputText value="#{personne.nomPersonnel}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Prénom" />
                        </f:facet>
                        <h:outputText value="#{personne.prenom}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Statut" />
                        </f:facet>
                        <h:outputText value="#{personne.statut}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Numéro de télephone " />
                        </f:facet>
                        <h:outputText value="#{personne.numTelephone}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="fonction " />
                        </f:facet>
                        <h:outputText value="#{personne.fonction}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Agence " />
                        </f:facet>
                        <h:outputText value="#{personne.agence}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="login" />
                        </f:facet>
                        <h:outputText value="#{personne.login}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="mot de passe " />
                        </f:facet>
                        <h:outputText value="#{personne.mot_de_passe}" />
                    </rich:column>
            <rich:column>
                <h:commandButton action="#{perGest.deletePersonnel(personne.cin)}"  value="Supprimer">
                    <f:setPropertyActionListener value="#{personne}" target="#{perGest.p}"/>
     
     
                </h:commandButton>
                </rich:column>
     
                </rich:dataTable>
                <rich:dataScroller for="table" maxPages="4" fastStep="3"/>
     
            </h:panelGrid>
        </h:form>

  2. #2
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    peux-tu nous montrer le hacking bean qui tourne derrière?

    eric

  3. #3
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut
    voile le bean personnelGestionImp sur le package METIER :

    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
     
    package Metier;
     
    import DAO.*;
    import java.util.List;
     
    /**
     *
     * @author Mohamed amine
     */
    public class personnelGestionImp extends personnelDaoImp  implements personnelGestion{
     
        private PersonnelDAO PerDao ;
        personnel p;
     
        private String cin ;
        private String nom ;
     
     
        public personnelGestionImp() {
     
        }
     
        public String getCin() {
            return cin;
        }
     
        public void setCin(String cin) {
            this.cin = cin;
        }
     
        public String getNom() {
            return nom;
        }
     
        public void setNom(String nom) {
            this.nom = nom;
        }
     
        public personnel getP() {
            return p;
        }
     
        public void setP(personnel p) {
            this.p = p;
        }
     
     
        public PersonnelDAO getPerDao() {
            return PerDao;
        }
     
        public void setPerDao(PersonnelDAO PerDao) {
            this.PerDao = PerDao;
        }
     
      public List<personnel> getPersonnel () throws Exception{
     
          return (List<personnel>) super.getPersonnel();
     
      }
     
      public List<personnel> RechercheP(String cin) throws Exception {
     
          return (List<personnel>) super.Rechercher(cin); 
      }
     
     public boolean admin(String login,String password)throws Exception {
    return super.TestAdministrateur(login, password); 
    }
     
      public void deletePersonnel()throws Exception{
    PerDao.deleteP(cin);
    }
     
    public void updatePersonnel(personnel per)throws Exception{
    super.updatePersonnel(per); 
    }
     
    public void insertLivre(personnel p)throws Exception{
     PerDao.insertPersonnel(p);
    }
     
    }
    et voila le bean personnelDaoImp sur le package DAO :

    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
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package DAO;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    import org.springframework.jdbc.core.JdbcTemplate;
     
    /**
     *
     * @author Mohamed amine
     */
    public class personnelDaoImp  implements PersonnelDAO{
    private  String driver;
    private  String url;
    private  String user;
    private  String password;
     
     
        public personnelDaoImp() {
    driver="com.mysql.jdbc.Driver";
    url="jdbc:mysql://localhost/derichebourg";
    user="root";
    password="";
        }
     
     
    public  void deleteP(String cin) throws Exception{
    Class.forName(driver).newInstance();
    Connection cnx = DriverManager.getConnection(url, user,password);
    Statement stmt = cnx.createStatement();
    try{
    String q ="delete from personnel where cin='"+cin+"'";
    stmt.executeUpdate(q);
     } catch (SQLException e){
           stmt.close();
           cnx.close();
        } 
    }
     
    public void updatePersonnel(personnel pers)throws Exception {
    Class.forName(driver).newInstance();
    Connection cnx = DriverManager.getConnection(url, user,password);
    Statement stmt = (Statement) cnx.createStatement();
    try{
    String q="update personnel set cin='"+pers.getCin()+"', nomPersonnel='"+pers.getNomPersonnel()+"',prenom='"+pers.getPrenom()+"',statut='"+pers.getStatut()+"',numTelephone='"+pers.getNumTelephone()+"',fonction='"+pers.getFonction()+"',numAgence='"+pers.getAgence()+"',login='"+pers.getLogin()+"',mot_de_passe='"+pers.getMot_de_passe()+"' where cin='"+pers.getCin()+"'";
    stmt.executeUpdate(q); int update = stmt.executeUpdate(q);
     } catch (SQLException e){
           stmt.close();
           cnx.close();
        }
    }
     
     
        public  boolean TestAdministrateur(String login,String pass)throws Exception{
    Class.forName(driver).newInstance();
    Connection cnx = DriverManager.getConnection(url,user,password);
    Statement stmt = (Statement) cnx.createStatement();
    try{
    String q = "select * from personnel";
    ResultSet rs = stmt.executeQuery(q);
    while (rs.next()) {
    if((login.equalsIgnoreCase(rs.getString("login")))&&(pass.equalsIgnoreCase(rs.getString("mot_de_passe"))))
    return true;
    }
     
     
        } catch(SQLException e){
            cnx.close();
            stmt.close();
        }
    return false;
     
    }
     
        public   List<personnel> getPersonnel() throws Exception {
    List<personnel> c = new ArrayList<personnel>();
    Class.forName(driver).newInstance();
    Connection cnx = DriverManager.getConnection(url, user,password);
    Statement stmt = (Statement) cnx.createStatement();
    try{
    String q = "SELECT cin,nomPersonnel,prenom,NOMSTATUT,numTelephone,fonction,nomAgence,login,mot_de_passe FROM personnel p , statut s , Agence a WHERE p.statut=s. NumSTATUT and a.numAgence=p.numAgence ";
    ResultSet rs = stmt.executeQuery(q);
     
    while (rs.next()) {
    String cin  = rs.getString("cin");
    String nom = rs.getString("nomPersonnel");
    String prenom = rs.getString("prenom");
    String statut = rs.getString("NOMSTATUT");
    String telephone = rs.getString("numTelephone");
    String fonction = rs.getString("fonction");
    String Agence = rs.getString("nomAgence");
    String login = rs.getString("login");
    String passe = rs.getString("mot_de_passe");
     
    c.add(new personnel(cin, nom, prenom, statut, telephone, fonction, Agence, login, passe));
    }
     
    } catch (SQLException e){
           stmt.close();
           cnx.close();
     
        }
    return c ;
    }
     
     
     
     
        public   List<personnel> Rechercher(String cinP) throws Exception {
    List<personnel> c = new ArrayList<personnel>();
    Class.forName(driver).newInstance();
    Connection cnx = DriverManager.getConnection(url, user,password);
    Statement stmt = (Statement) cnx.createStatement();
    try{
    String q = "SELECT cin,nomPersonnel,prenom,NOMSTATUT,numTelephone,fonction,nomAgence,login,mot_de_passe FROM personnel p , statut s , Agence a WHERE p.statut=s. NumSTATUT and a.numAgence=p.numAgence and p.cin='" +cinP+"' ";
    ResultSet rs = stmt.executeQuery(q);
     
    while (rs.next()) {
    String cin  = rs.getString("cin");
    String nom = rs.getString("nomPersonnel");
    String prenom = rs.getString("prenom");
    String statut = rs.getString("NOMSTATUT");
    String telephone = rs.getString("numTelephone");
    String fonction = rs.getString("fonction");
    String Agence = rs.getString("nomAgence");
    String login = rs.getString("login");
    String passe = rs.getString("mot_de_passe");
     
    c.add(new personnel(cin, nom, prenom, statut, telephone, fonction, Agence, login, passe));
    }
     
    } catch (SQLException e){
           stmt.close();
           cnx.close();
     
        }
    return c ;
    }
     
     
    public void insertPersonnel(personnel p) throws Exception{
    Class.forName(driver).newInstance();
     
    Connection cnx = DriverManager.getConnection(url, user,password);
    Statement stmt = (Statement) cnx.createStatement();
    try{
    String q = "insert into personnel(cin,statut,numAgence,nomPersonnel,prenom,numTelephone,adresse,fonction,login,mot_de_passe,mail)value('" + p.getCin() + "','" +
    p.getStatut() + "','" + p.getAgence() + "','" + p.getNomPersonnel() +"','" +p.getPrenom()+"','" +p.getNumTelephone()+"','" +p.getAdresse()+"','" +p.getFonction()+"','" +p.getLogin()+"','" +p.getMot_de_passe()+p.getMail()+ "')";
    int update = stmt.executeUpdate(q);
     
        } catch (SQLException e){
           stmt.close();
           cnx.close();
        }
    }
     
     
     
    }

  4. #4
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    ou as tu definit :
    eric

  5. #5
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut
    show est définit dans le fichier de configuration de jsf :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <managed-bean>
    <managed-bean-name>show</managed-bean-name>
    <managed-bean-class>Presentation.AfficherPersonnel</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>perGest</property-name>
    <value>#{perGest}</value>
    </managed-property>
    </managed-bean>

    et voila le code de la classe AfficherPersonnel.java ou il y a lista

    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
     
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package Presentation;
     
    import java.util.ArrayList;
    import java.util.List;
    import DAO.personnel;
    import DAO.personnelDaoImp;
    import Metier.personnelGestion;
    import Metier.personnelGestionImp; 
    import javax.annotation.ManagedBean;
    import org.springframework.dao.support.DaoSupport;
     
     
    /**
     *
     * @author Mohamed amine
     */
     
    public class AfficherPersonnel {
     
     
       private personnelGestion perGest ;
       private List<personnel> lista  = new ArrayList<personnel>();
     
     
       private String cin ;
     
     
     
        public AfficherPersonnel() {
    perGest=new personnelGestionImp();
    try {
    setLista(listter());
     
    } catch (Exception exception) {
    }
    } 
     
        public List<personnel> getLista() {
            return lista;
        }
     
        public void setLista(List<personnel> lista) {
            this.lista = lista;
        }
     
     
     
        public personnelGestion getPerGest() {
            return perGest;
        }
     
        public void setPerGest(personnelGestion perGest) {
            this.perGest = perGest;
        }
     
        public String getCin() {
            return cin;
        }
     
        public void setCin(String cin) {
            this.cin = cin;
        }
     
     
     
     public List<personnel> listter() throws Exception
    {
    return (List<personnel>)(perGest.getPersonnel());
    }
     
    }
    Images attachées Images attachées  

  6. #6
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut refresh
    Veuillez m'aider s'il vous plait j'en ai marre de ce probleme

  7. #7
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    lista n´est pas rafraichit après suppression.

    eric

  8. #8
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut
    qu'est ce que je dois ajouter pour qu'elle se rafraîchit

  9. #9
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    comment d´abord par remplacer ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    public AfficherPersonnel() {
    perGest=new personnelGestionImp();
    try {
    setLista(listter());
     
    } catch (Exception exception) {
    }
    }
    par:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
      private DataModel<personnel> dataModel = new ListDataModel<personnel>();
      public AfficherPersonnel() {
    } 
    
    public void setLista(List<personnel> lista) {
            this.lista = lista;
            this.dataModel.setWrappedData(this.lista);
        }
    
    public DataModel<personnel> getDataModel() {
    		return this.dataModel;
    	}
    et complete ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <managed-bean>
    <managed-bean-name>show</managed-bean-name>
    <managed-bean-class>Presentation.AfficherPersonnel</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>perGest</property-name>
    <value>#{perGest}</value>
    </managed-property>
    <managed-property>
    <property-name>lista</property-name>
    <value>#{perGest.personnel}</value>
    </managed-property>
    </managed-bean>
    et dans la méthode :
    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
    <rich:dataTable value="#{show.dataModel}" var="personne" id="table" rows="5">
     
     
     
         <rich:column>
                        <f:facet name="header">
                            <h:outputText value="CIN " />
                        </f:facet>
                        <h:outputText value="#{personne.cin}"/>
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Nom" />
                        </f:facet>
                        <h:outputText value="#{personne.nomPersonnel}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Prénom" />
                        </f:facet>
                        <h:outputText value="#{personne.prenom}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Statut" />
                        </f:facet>
                        <h:outputText value="#{personne.statut}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Numéro de télephone " />
                        </f:facet>
                        <h:outputText value="#{personne.numTelephone}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="fonction " />
                        </f:facet>
                        <h:outputText value="#{personne.fonction}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Agence " />
                        </f:facet>
                        <h:outputText value="#{personne.agence}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="login" />
                        </f:facet>
                        <h:outputText value="#{personne.login}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="mot de passe " />
                        </f:facet>
                        <h:outputText value="#{personne.mot_de_passe}" />
                    </rich:column>
            <rich:column>
                <h:commandButton action="#{perGest.deletePersonnel(personne.cin)}"  value="Supprimer">
                    <f:setPropertyActionListener value="#{personne}" target="#{perGest.p}"/>
     
     
                </h:commandButton>
                </rich:column>
     
                </rich:dataTable>
    eric

  10. #10
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut
    salut eric


    j'ai essayé tt ça mais le problème reste le même la table ne se rafraichit pas jusqu’à que j'actualise la page ou je clique deux fois sur le bouton supprimé par contre coté base de données marche très bien

  11. #11
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut
    salut eric


    je pense qu'au moment de l'appel de la méthode deletePersonnel () qui se trouve dans le beans je dois aussi appeler la nouvelle liste des personnels .

    si vous avez une proposition vous me le dites pour la essayer parce que j'en ai marre de cette erreur et merci eric pour le suivi .


    voila en fait mon beans :
    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
     
    public class personnelGestionImp extends personnelDaoImp  implements personnelGestion{
     
        private PersonnelDAO PerDao ;
      private   personnel p;
         private List<personnel> lista  = new ArrayList<personnel>();
     
        private String cin ;
        private String nom ;
     
     
        public personnelGestionImp() {
     
        }
     
        public List<personnel> getLista() {
            return lista;
        }
     
        public void setLista(List<personnel> lista) {
            this.lista = lista;
        }
     
     
     
        public String getCin() {
            return cin;
        }
     
        public void setCin(String cin) {
            this.cin = cin;
        }
     
        public String getNom() {
            return nom;
        }
     
        public void setNom(String nom) {
            this.nom = nom;
        }
     
        public personnel getP() {
            return p;
        }
     
        public void setP(personnel p) {
            this.p = p;
        }
     
     
        public PersonnelDAO getPerDao() {
            return PerDao;
        }
     
        public void setPerDao(PersonnelDAO PerDao) {
            this.PerDao = PerDao;
        }
     
      public List<personnel> getPersonnel () throws Exception{
     
          return (List<personnel>) super.getPersonnel();
     
      }
     
     
      public  List<personnel> geAll () throws Exception{
     
          return (List<personnel>) super.getPersonnel();
      }
     
     
     public boolean admin(String login,String password)throws Exception {
    return super.TestAdministrateur(login, password); 
    }
     
      public void deletePersonnel()throws Exception{
    PerDao.deleteP(cin);
    }
     
    public void updatePersonnel(personnel per)throws Exception{
    super.updatePersonnel(per); 
    }
     
    public void insertPerso(personnel p)throws Exception{
     PerDao.insertPersonnel(p);
    }
     
    }

    et la méthode deleteP dans la couche DAO


    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
     
     
     
    public  void deleteP(String cin) throws Exception{
    Class.forName(driver).newInstance();
    Connection cnx = DriverManager.getConnection(url, user,password);
    Statement stmt = cnx.createStatement();
    try{
    String q ="delete from personnel where cin='"+cin+"'";
    stmt.executeUpdate(q);
     } catch (SQLException e){
           stmt.close();
           cnx.close();
        } 
    }


    et la classe afficher () ou show :

    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
     
    public class AfficherPersonnel {
     
     
       private personnelGestion perGest ;
       private List<personnel> lista  = new ArrayList<personnel>();
       private String cin ;
     
     
     
        public AfficherPersonnel() {
    perGest=new personnelGestionImp();
    try {
    setLista(listter());
     
    } catch (Exception exception) {
    }
    } 
     
        public List<personnel> getLista() {
            return lista;
        }
     
        public void setLista(List<personnel> lista) {
            this.lista = lista;
        }
     
     
     
        public personnelGestion getPerGest() {
            return perGest;
        }
     
        public void setPerGest(personnelGestion perGest) {
            this.perGest = perGest;
        }
     
        public String getCin() {
            return cin;
        }
     
        public void setCin(String cin) {
            this.cin = cin;
        }
     
     
     
     public List<personnel> listter() throws Exception
    {
    return (List<personnel>)(perGest.getPersonnel());
    }
     
     
     
     
    }


    et enfin la page administration.xhtml :

    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
     
    <a4j:status onstart="#{rich:component('statPane')}.show()" onstop="#{rich:component('statPane')}.hide()" />
        <h:form id="form">
     
            <rich:dataTable value="#{show.lista}" var="personne"  iterationStatusVar="it" id="table" rows="12">
     
                <rich:column filterValue="#{show.cin}"
                             filterExpression="#{fn:containsIgnoreCase(personne.cin,show.cin)}">
                        <f:facet name="header">
                            <h:panelGroup>
                            <h:outputText value="CIN " />
                            <h:inputText  value="#{show.cin}">
                                <a4j:ajax event="blur" render="table" execute="@this"/>
                            </h:inputText>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{personne.cin}"/>
                    </rich:column>
     
               <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Nom" />
                        </f:facet>
                   <h:outputText value="#{personne.nomPersonnel}" />
                    </rich:column>
     
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Prénom" />
                        </f:facet>
                        <h:outputText value="#{personne.prenom}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Statut" />
                        </f:facet>
                        <h:outputText value="#{personne.statut}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Numéro de télephone " />
                        </f:facet>
                        <h:outputText value="#{personne.numTelephone}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Fonction " />
                        </f:facet>
                        <h:outputText value="#{personne.fonction}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Agence " />
                        </f:facet>
                        <h:outputText value="#{personne.agence}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Login" />
                        </f:facet>
                        <h:outputText value="#{personne.login}" />
                    </rich:column>
                <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Mot de passe " />
                        </f:facet>
                        <h:outputText value="#{personne.mot_de_passe}" />
                    </rich:column>
     
                <rich:column>
                    <a4j:commandLink styleClass="no-decor" execute="@this" render="@none"  
                        oncomplete="#{rich:component('confirmPane')}.show()">
                        <h:graphicImage value="dist/img/ecrase.png" alt="Supprimer cet utilisateur"  style="width: 15px;height:auto"/>
                        <a4j:param value="#{personne.cin}" assignTo="#{perGest.cin}"/>
     
                    </a4j:commandLink>
     
              <a4j:commandLink styleClass="no-decor" render="editGrid" execute="@this"
                oncomplete="#{rich:component('editPane')}.show()">
                 <h:graphicImage value="../dist/img/modifier.jpg" alt="edit"  style="width: 15px;height:auto" />
                 <a4j:param value="#{personne.cin}" assignTo="#{perGest.cin}" />
                 <f:setPropertyActionListener target="#{perGest.p}" value="#{personne}"/>
              </a4j:commandLink>
                      </rich:column>
     
               <f:facet name="footer">
                  <rich:dataScroller fastStep="3"/>
                </f:facet>
            </rich:dataTable>
     
     
            <!-- fonction supprimer -->
            <a4j:jsFunction name="remove" action="#{perGest.deletePersonnel}" render="table" execute="@this"
                oncomplete="#{rich:component('confirmPane')}.hide();" />
     
              <!-- PopUp chargement -->
            <rich:popupPanel id="statPane" autosized="true">
                <h:graphicImage value="/dist/img/chargement.png" alt="ai" style="width: 17px;height:auto" />
                Please wait...
            </rich:popupPanel>
     
               <!-- PopUp delete -->
            <rich:popupPanel id="confirmPane" autosized="true">
                Voulez-vous vraiment supprimer cet utilisateur?
                <a4j:commandButton value="Cancel" onclick="#{rich:component('confirmPane')}.hide(); return false;" />
                <a4j:commandButton value="Supprimer"  onclick="remove(); return false;" />
            </rich:popupPanel>
     
                <!-- PopUp  update -->
            <rich:popupPanel header="Edit Personnel" id="editPane" domElementAttachment="parent" width="400" height="170">
                <h:panelGrid columns="1" id="editGrid">
                    <h:outputText value="cin"/>
                    <h:inputText value="#{personne.cin}"  id="cin"></h:inputText>
     
     
                </h:panelGrid>
                <a4j:commandButton value="Store" action="#{perGest.updatePersonnel(personne)}" render="table" execute="editPane"
                    oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editPane')}.hide();}" />
                <a4j:commandButton value="Cancel" onclick="#{rich:component('editPane')}.hide(); return false;" />
            </rich:popupPanel>
     
        </h:form>

  12. #12
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    la methode delete doit être dans la classe AfficherPersonnel.java

    eric

  13. #13
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut
    Bonjour eric

    j'ai essayé d'implémenter la méthode delete dans la classe AfficherPersonnel.java mais en vain , par contre la méthode tester pour l'authentification que je l'avais mis sur la classe Authentification.java marche tres bien , je ne sais pas d'ou vient le probleme .


    voici la méthode supprimer que j'ai implémenté dans la classe AfficherPersonnel :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    public String Supprimer()throws Exception{
       return Delet(this.cin);
    }
    public String Delet(String cin) throws Exception {
    this.perGest.deleteP(cin);
    return "succes";
    }

    voici la definition sur le fichier de configuraion de 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
     
     
     
    <managed-bean>
    <managed-bean-name>show</managed-bean-name>
    <managed-bean-class>Presentation.AfficherPersonnel</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>perGest</property-name>
    <value>#{perGest}</value>
    </managed-property>
    </managed-bean>
     
    <navigation-rule>
    <from-view-id>/administration.xhtml</from-view-id>
    <navigation-case>
    <from-outcome>succes</from-outcome>
    <to-view-id>/administration.xhtml</to-view-id>
    </navigation-case>
    </navigation-rule>


    et enfin l'appel de la méthode dans la page administration.xhtml


    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
     
     
     <a4j:commandLink styleClass="no-decor" execute="@this" render="@none"
                        oncomplete="#{rich:component('confirmPane')}.show()">
                        <h:graphicImage value="dist/img/ecrase.png" alt="Supprimer cet utilisateur"  style="width: 15px;height:auto"/>
                        <a4j:param value="#{personne.cin}" assignTo="#{show.cin}"/>
     
                    </a4j:commandLink>
     
     
     <!-- fonction supprimer -->
            <a4j:jsFunction name="remove" action="#{show.Supprimer}" render="table"
                oncomplete="#{rich:component('confirmPane')}.hide();" />
     
     
        <!-- PopUp delete -->
            <rich:popupPanel id="confirmPane" autosized="true">
                Voulez-vous vraiment supprimer cet utilisateur?
                <a4j:commandButton value="Cancel" onclick="#{rich:component('confirmPane')}.hide(); return false;" />
                <a4j:commandButton value="Supprimer"  onclick="remove(); return false;"/>
            </rich:popupPanel>

  14. #14
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    commence d´abord par enlever ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    perGest=new personnelGestionImp();
    car tu l´injecte deja dans le fichier de configuration.

    dans la methode :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    public String Delet(String cin) throws Exception {
    this.perGest.deleteP(cin);
    setLista(listter());
    return "succes";
    }
    que se passes-t-il s´il ya erreur dans la methode Delet(...)?
    en passant, les noms de methodes commencent par des minuscules et les noms des classes par des majuscules.

    Eric

  15. #15
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut
    Salut eric


    Comme je t'avais dit j'ai ajouté une autre page supprimer.xhtml avec une zone de texte et un bouton pour supprimer un personnel avec son cin , bon apres la supression en ajoutant " setLista(listter()); " comme vous m'avez dit dans la méthode delet() , ça marche tres tres bien la liste se rafraichit apres le retour à la page administration.xhtml mais ça ne reste pas pratique , est ce qu'il y a moyen pour supprimer un utilisateur dans la meme page ou il y a la table des personnels .

    je veux faire comme ceci :
    Images attachées Images attachées  

  16. #16
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    la c´est quelle page?
    et tu veux supprimer dans quelle page et rester dans quelle page?
    car je ne comprend plus rien.

    eric

  17. #17
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut
    Bonjour eric

    vous allez trouver une capture ci dessous qui résume tout :

    et voici le code de la page test.xhtml dont j'effectue la supression , ici dans cette page je fais appel à la méthode supprimer de la classe AffichePersonnel.java et ça fonctionne sans aucun probleme .

    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
     
     <f:view>
     <h:form>
         <rich:panel header="Supprimer un utilisateur" style=" width: 400px ; height:160px; position:relative ; left:270px ;top:50px;background-color: snow">
     
     
                                <table>
                                    <tr>
                                        <td> <h:outputText value="cin: " /></td>
     
                                        <td>  <h:inputText value="#{show.cin}" >
     
                                        <f:validateLength minimum="1" maximum="30" />
     
                                  </h:inputText>  </td>
     
                                    </tr> <br></br>
     
     
     
     
                                    <tr>
                      <td>  <h:commandButton  onclick="if (! confirm('Vous voulez vraiment supprimer cet utilisateur?')) return false"
                              value="Supprimer"  action="#{show.Supprimer}" style="position: relative ; top:20px;left:150px" /> </td>
                                   </tr>
                                </table>
     
                            </rich:panel>
        </h:form>
    </f:view>

    voici le code de la page administration.xhtml , ici comme vous voyez je fais appel à lista (liste des users ) depuis show = AfficherPersonnel.java ça me donne un résultat mais quand j'appelle la méthode supprimer de la meme classe (AfficherPersonnel.java ) pour supprimer un enregistrement ça ne fonctionne pas .

    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
     
     <h:form id="form">
     
            <rich:dataTable value="#{show.lista}" var="personne"  iterationStatusVar="it" id="table" rows="12">
     
                <rich:column filterValue="#{add.cin}"
                             filterExpression="#{fn:containsIgnoreCase(personne.cin,add.cin)}">
                        <f:facet name="header">
                            <h:panelGroup>
                            <h:outputText value="CIN " />
                            <h:inputText  value="#{add.cin}">
                                <a4j:ajax event="blur" render="table" execute="@this"/>
                            </h:inputText>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{personne.cin}"/>
                    </rich:column>
     
               <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Nom" />
                        </f:facet>
                   <h:outputText value="#{personne.nomPersonnel}" />
                    </rich:column>
     
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Prénom" />
                        </f:facet>
                        <h:outputText value="#{personne.prenom}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Statut" />
                        </f:facet>
                        <h:outputText value="#{personne.statut}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Numéro de télephone " />
                        </f:facet>
                        <h:outputText value="#{personne.numTelephone}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Fonction " />
                        </f:facet>
                        <h:outputText value="#{personne.fonction}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Agence " />
                        </f:facet>
                        <h:outputText value="#{personne.agence}" />
                    </rich:column>
     
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Login" />
                        </f:facet>
                        <h:outputText value="#{personne.login}" />
                    </rich:column>
                <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Mot de passe " />
                        </f:facet>
                        <h:outputText value="#{personne.mot_de_passe}" />
                    </rich:column>
     
                <rich:column>
                    <a4j:commandLink styleClass="no-decor" execute="@this" render="@none"
                        oncomplete="#{rich:component('confirmPane')}.show()">
                        <h:graphicImage value="dist/img/ecrase.png" alt="Supprimer cet utilisateur"  style="width: 15px;height:auto"/>
                        <a4j:param value="#{personne.cin}" assignTo="#{show.cin}"/>            
                    </a4j:commandLink>      
                      </rich:column>
     
               <f:facet name="footer">
                  <rich:dataScroller fastStep="3"/>
                </f:facet>
            </rich:dataTable>
     
     
            <!-- fonction supprimer -->
            <a4j:jsFunction name="remove"  action="#{show.Supprimer}"  render="table" execute="@this"
                oncomplete="#{rich:component('confirmPane')}.hide();" />
     
               <!-- PopUp delete -->
            <rich:popupPanel id="confirmPane" autosized="true">
                Voulez-vous vraiment supprimer cet utilisateur?
                <a4j:commandButton value="Cancel" onclick="#{rich:component('confirmPane')}.hide(); return false;" />
                <a4j:commandButton value="Supprimer" onclick="remove(); return false;"/>
            </rich:popupPanel>
     
     
        </h:form>

    Et voici le code de show (AfficherPersonnel.java) :

    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
     
     
    public class AfficherPersonnel {
     
     
       private personnelGestion perG ;
       private List<personnel> lista  = new ArrayList<personnel>();
       private String cin ;
     
     
        public personnelGestion getPerG() {
            return perG;
        }
     
        public void setPerG(personnelGestion perG) {
            this.perG = perG;
        }
     
     
     
        public AfficherPersonnel() {
        perG= new personnelGestionImp ();
    try {
    setLista(listter());
     
    } catch (Exception exception) {
    }
    } 
     
        public List<personnel> getLista() {
            return lista;
        }
     
        public void setLista(List<personnel> lista) {
            this.lista = lista;
        }
     
     
     
        public personnelGestion getPerGest() {
            return perG;
        }
     
        public void setPerGest(personnelGestion perGest) {
            this.perG = perGest;
        }
        public String getCin() {
            return cin;
        }
     
        public void setCin(String cin) {
            this.cin = cin;
        }
     
    public List<personnel> listter() throws Exception{
    return (List<personnel>)(perG.getPersonnel());
    }
     
    public String Supprimer()throws Exception{
     
       return Delet(this.cin);
    }
    public String Delet(String cin)throws Exception
    {
    this.perG.deleteP(cin);
    setLista(listter());
    return "succes";
    }
    }

    et voici le code du bean PersonnelGestionImp :

    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
     
     
    public class personnelGestionImp extends personnelDaoImp  implements personnelGestion{
     
        private PersonnelDAO PerDao ;
     
     
     
        public personnelGestionImp() {
     
        }
     
     
        public PersonnelDAO getPerDao() {
            return PerDao;
        }
     
        public void setPerDao(PersonnelDAO PerDao) {
            this.PerDao = PerDao;
        }
     
      public List<personnel> getPersonnel () throws Exception{
     
          return (List<personnel>) super.getPersonnel();
     
      }
     
     public boolean admin(String login,String password)throws Exception {
    return super.TestAdministrateur(login, password); 
    }
     
      public void deletePersonnel(String cin)throws Exception{
            PerDao.deleteP(cin);
     
    }
     
    public void updatePersonnel(personnel per)throws Exception{
    super.updatePersonnel(per); 
    }
     
    public void insertPerso(personnel p)throws Exception{
     PerDao.insertPersonnel(p);
    }
     
    }


    et l'interface PersonnelGestion :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
     
    public interface personnelGestion {
     
      public boolean admin(String login,String mot_de_passe) throws Exception;
      public List getPersonnel() throws  Exception ;
      public void  deleteP(String cin) throws Exception ;
      public void updatePersonnel(personnel pers)throws Exception;
      public void insertPersonnel(personnel p)throws Exception;
     
    }
    Images attachées Images attachées   

  18. #18
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    voici comment je parvient a le faire:
    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
     
    <h:form>
        .....
     <rich:dataTable>  
      .....
     
     <rich:column>
                    <a4j:commandLink styleClass="no-decor" execute="@this" render="@none"
                        oncomplete="#{rich:component('confirmPane')}.show()">
                        <h:graphicImage value="/images/icons/delete.gif" alt="delete" />
                        <a4j:param value="#{personne.cin}" assignTo="#{show.cin}" />
                    </a4j:commandLink>
     
                </rich:column>
    </rich:dataTable>
     <a4j:jsFunction name="remove" action="#{show.Supprimer}" render="table" execute="@this"
                oncomplete="#{rich:component('confirmPane')}.hide();" />
     
       <!-- PopUp delete -->
            <rich:popupPanel id="confirmPane" autosized="true">
                Voulez-vous vraiment supprimer cet utilisateur?
                <a4j:commandButton value="Cancel" onclick="#{rich:component('confirmPane')}.hide(); return false;" />
                <a4j:commandButton value="Supprimer" onclick="remove(); return false;"/>
            </rich:popupPanel>
    </h:form>
    et dans ma bean:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
       public void Supprimer()  throws Exception{ 
            this.perG.deleteP(this.cin);
            setLista(listter());
        }
    si cela ne marche pas, essaie de me donner ce qui est ecrit dans le fichier .log ou dans la console.

    Eric

  19. #19
    Membre du Club
    Homme Profil pro
    éléve ingénieur
    Inscrit en
    Mai 2015
    Messages
    75
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : éléve ingénieur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 75
    Points : 57
    Points
    57
    Par défaut
    Salut Eric


    Ceci je l'ai déjà essayé mais ne marche pas dans la page (administration.xhtml) ou il y a la liste des personnels , il faut que je crée une page par exemple (test.xhtml) avec une zone de texte et un bouton et appeler la méthode show.supprimer() pour qu'elle marche .

    voici ce que vous m'avez demandé :

    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
     
     
    Infos: Security startup service called
    Infos: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
    Infos: Realm admin-realm of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
    Infos: Realm file of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
    Infos: Realm certificate of classtype com.sun.enterprise.security.auth.realm.certificate.CertificateRealm successfully created.
    Infos: Security service(s) started successfully....
    Infos: Created HTTP listener http-listener-1 on port 8080
    Infos: Created HTTP listener http-listener-2 on port 8181
    Infos: Created HTTP listener admin-listener on port 4848
    Infos: Created virtual server server
    Infos: Created virtual server __asadmin
    Infos: Virtual server server loaded system default web module
    Avertissement: Error in annotation processing: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
    Infos: PWC1412: WebModule[/atelier] ServletContext.log():No Spring WebApplicationInitializer types detected on classpath
    Infos: Initialisation de Mojarra 2.0.2 (FCS b10) pour le contexte '/atelier'
    Infos: Hibernate Validator bean-validator-3.0-JBoss-4.0.2
    Infos: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    Infos: Selected fallback cache factory
    Infos: Creating LRUMap cache instance using parameters: {contextConfigLocation=/WEB-INF/applicationContext.xml, javax.faces.PROJECT_STAGE=Development, com.sun.faces.validateXml=true, com.sun.faces.forceLoadConfiguration=true, javax.faces.STATE_SAVING_METHOD=client, org.richfaces.CONTROL_SKINNING=enable, com.sun.faces.verifyObjects=false, org.richfaces.SKIN=blueSky}
    Infos: Creating LRUMap cache instance of 512 items capacity
    Infos: RichFaces Core Implementation by JBoss, a division of Red Hat, Inc., version v.4.1.0.Final
    Infos: Monitoring jndi:/server/atelier/WEB-INF/faces-config.xml for modifications
    Infos: PWC1412: WebModule[/atelier] ServletContext.log():Initializing Spring root WebApplicationContext
    Infos: Root WebApplicationContext: initialization started
    Infos: Refreshing Root WebApplicationContext: startup date [Fri May 20 23:54:13 WEST 2016]; root of context hierarchy
    Infos: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    Infos: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1b27fb2: defining beans [livDao,livGest]; root of factory hierarchy
    Infos: Root WebApplicationContext: initialization completed in 1744 ms
    Infos: Loading application atelier at /atelier
    Infos: Loading atelier Application done is 30485 ms
    Infos: Initialisation de Mojarra 2.0.2 (FCS b10) pour le contexte '/Derichebourg'
    Infos: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    Infos: Selected fallback cache factory
    Infos: Creating LRUMap cache instance using parameters: {contextConfigLocation=/WEB-INF/applicationContext.xml, javax.faces.PROJECT_STAGE=Development, com.sun.faces.validateXml=true, com.sun.faces.forceLoadConfiguration=true, javax.faces.STATE_SAVING_METHOD=client, org.richfaces.CONTROL_SKINNING=enable, com.sun.faces.verifyObjects=false, org.richfaces.SKIN=blueSky}
    Infos: Creating LRUMap cache instance of 512 items capacity
    Infos: RichFaces Core Implementation by JBoss, a division of Red Hat, Inc., version v.4.1.0.Final
    Infos: Monitoring jndi:/server/Derichebourg/WEB-INF/faces-config.xml for modifications
    Infos: PWC1412: WebModule[/Derichebourg] ServletContext.log():Initializing Spring root WebApplicationContext
    Infos: Root WebApplicationContext: initialization started
    Infos: Refreshing Root WebApplicationContext: startup date [Fri May 20 23:54:27 WEST 2016]; root of context hierarchy
    Infos: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    Infos: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@19d9248: defining beans [PerDao,perGest,AgDao,AgGest]; root of factory hierarchy
    Infos: Root WebApplicationContext: initialization completed in 1932 ms
    Infos: Loading application Derichebourg at /Derichebourg
    Infos: Loading Derichebourg Application done is 14346 ms
    Infos: GlassFish Server Open Source Edition 3.0.1 (22) startup time : Felix(17263ms) startup services(47894ms) total(65157ms)
    Infos: Binding RMI port to *:8686
    Infos: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    Infos: JMXStartupService: Started JMXConnector, JMXService URL = service:jmx:rmi://Mohamedamine-PC.home:8686/jndi/rmi://Mohamedamine-PC.home:8686/jmxrmi
    Infos: Created HTTP listener http-listener-1 on port 8080
    Infos: Grizzly Framework 1.9.18-o started in: 9ms listening on port 8080
    Avertissement: Exception while starting bundle com.sun.enterprise.osgi-adapter [61]
    org.osgi.framework.BundleException: Activator start error in bundle com.sun.enterprise.osgi-adapter [61].
            at org.apache.felix.framework.Felix.activateBundle(Felix.java:1751)
            at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
            at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
            at org.jvnet.hk2.osgimain.Main.start(Main.java:140)
            at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
            at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
            at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
            at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
            at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
            at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.NullPointerException
            at org.glassfish.admin.monitor.jvm.JVMStatsProviderBootstrap.postConstruct(JVMStatsProviderBootstrap.java:87)
            at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
            at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
            at java.security.AccessController.doPrivileged(Native Method)
            at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
            at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
            at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
            at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
            at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
            at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:313)
            at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:128)
            at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:457)
            at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:401)
            at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:125)
            at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
            at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
            ... 9 more
     
    Infos: Created HTTP listener http-listener-1 on port 8080
    Infos: Grizzly Framework 1.9.18-o started in: 9ms listening on port 8080
    Infos: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\Users\Mohamed amine\.netbeans\6.9\config\GF3_1\domain1\autodeploy\bundles, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\Users\MOHAME~1\AppData\Local\Temp\fileinstall-8644319753373137752, felix.fileinstall.filter = null}
    Infos: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\Program Files\glassfish-3.0.1\glassfish\modules\autostart, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\Users\MOHAME~1\AppData\Local\Temp\fileinstall-7036501542174753561, felix.fileinstall.filter = null}
    Infos: Started bundle: file:/C:/Program%20Files/glassfish-3.0.1/glassfish/modules/autostart/osgi-web-container.jar
    Infos: Created HTTP listener http-listener-1 on port 8080
    Infos: Grizzly Framework 1.9.18-o started in: 5ms listening on port 8080
    Infos: Perform lazy SSL initialization for the listener 'http-listener-2'
    Infos: Created HTTP listener http-listener-2 on port 8181
    Infos: Grizzly Framework 1.9.18-o started in: 4ms listening on port 8181
    Infos: PWC1412: WebModule[/Derichebourg] ServletContext.log():Closing Spring root WebApplicationContext
    Infos: Closing Root WebApplicationContext: startup date [Fri May 20 23:54:27 WEST 2016]; root of context hierarchy
    Infos: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@19d9248: defining beans [PerDao,perGest,AgDao,AgGest]; root of factory hierarchy
    Infos: Updating configuration from org.apache.felix.fileinstall-autodeploy-bundles.cfg
    Infos: Installed C:\Program Files\glassfish-3.0.1\glassfish\modules\autostart\org.apache.felix.fileinstall-autodeploy-bundles.cfg
    Infos: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\Users\Mohamed amine\.netbeans\6.9\config\GF3_1\domain1\autodeploy\bundles, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\Users\MOHAME~1\AppData\Local\Temp\fileinstall-4238291873252451063, felix.fileinstall.filter = null}
    Infos: Initialisation de Mojarra 2.0.2 (FCS b10) pour le contexte '/Derichebourg'
    Infos: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    Infos: Selected fallback cache factory
    Infos: Creating LRUMap cache instance using parameters: {contextConfigLocation=/WEB-INF/applicationContext.xml, javax.faces.PROJECT_STAGE=Development, com.sun.faces.validateXml=true, com.sun.faces.forceLoadConfiguration=true, javax.faces.STATE_SAVING_METHOD=client, org.richfaces.CONTROL_SKINNING=enable, com.sun.faces.verifyObjects=false, org.richfaces.SKIN=blueSky}
    Infos: Creating LRUMap cache instance of 512 items capacity
    Infos: RichFaces Core Implementation by JBoss, a division of Red Hat, Inc., version v.4.1.0.Final
    Infos: Monitoring jndi:/server/Derichebourg/WEB-INF/faces-config.xml for modifications
    Infos: PWC1412: WebModule[/Derichebourg] ServletContext.log():Initializing Spring root WebApplicationContext
    Infos: Root WebApplicationContext: initialization started
    Infos: Refreshing Root WebApplicationContext: startup date [Fri May 20 23:55:13 WEST 2016]; root of context hierarchy
    Infos: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    Infos: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1979530: defining beans [PerDao,perGest,AgDao,AgGest]; root of factory hierarchy
    Infos: Root WebApplicationContext: initialization completed in 2200 ms
    Infos: Loading application Derichebourg at /Derichebourg
    Infos: Derichebourg was successfully deployed in 41*872 milliseconds.
    Infos: Perform lazy SSL initialization for the listener 'http-listener-2'
    Infos: Created HTTP listener http-listener-2 on port 8181
    Infos: Grizzly Framework 1.9.18-o started in: 6ms listening on port 8181
    Infos: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.

  20. #20
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    ton probleme se trouve a ces endroits, mais commencons par celui ci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <managed-bean>
    <managed-bean-name>show</managed-bean-name>
    <managed-bean-class>Presentation.AfficherPersonnel</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>perG</property-name>
    <value>#{perGest}</value>
    </managed-property>
    </managed-bean>

    mets ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    public void Supprimer() throws Exception {
    		System.out.println(cin);
    		this.Delet(cin);
    		return;
    	}
    et donnes moi le resultat
    Eric

Discussions similaires

  1. Réponses: 1
    Dernier message: 05/10/2012, 02h44
  2. Réponses: 0
    Dernier message: 24/05/2010, 22h02
  3. problème après suppression des tables
    Par pseudo88 dans le forum Développement
    Réponses: 4
    Dernier message: 20/04/2009, 12h20
  4. Réponses: 4
    Dernier message: 16/06/2008, 15h30
  5. [MySQL] Décrémenter automatiquement un champ de table après suppression d'une occurrence
    Par hicham_alaoui1 dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 15/09/2007, 16h51

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