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

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    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
    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 Expert 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
    Par défaut
    salut,
    peux-tu nous montrer le hacking bean qui tourne derrière?

    eric

  3. #3
    Membre confirmé
    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
    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 Expert 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
    Par défaut
    salut,
    ou as tu definit :
    eric

  5. #5
    Membre confirmé
    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
    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 confirmé
    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
    Par défaut refresh
    Veuillez m'aider s'il vous plait j'en ai marre de ce probleme

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