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

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

JSF Java Discussion :

Problème avec une DataTable


Sujet :

JSF Java

  1. #1
    Membre éclairé
    Homme Profil pro
    Inscrit en
    Mai 2011
    Messages
    790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Mai 2011
    Messages : 790
    Par défaut Problème avec une DataTable
    Bonjour,

    Mon but est d'afficher une table qui existe dans une base de données Oracle.
    J'ai établis le code du ManagedBean et la page mais pourtant ça ne marche pas.

    Voici le code :
    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
    package com.controller;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import org.hibernate.Session;
    import org.hibernate.Transaction;
     
    import com.dao.ContactDao;
    import com.dao.imp.ContactDaoImp;
    import com.model.Contact;
    import com.model.Utilisateur;
    import com.util.hibernateutil;
     
    public class ContactCtr   {
     
        private String numPieceCnt;
        private String nomNomCnt;
        private String nomPreCnt;
        private String adrAdrCnt;
        private String numGsmCnt;
        private String codTpceCnt;
        private List<Contact> contact=new ArrayList();
     
        ContactDao Cont= new ContactDaoImp();
     
        public List<Contact> getContact() {
            if(contact==null){
                contact = Cont.findallContact();
            }
            return contact;
        }
     
        public void setContact(List<Contact> contact) {
            this.contact = contact;
        }
     
        public String getNumPieceCnt() {
            return this.numPieceCnt;
        }
     
        public void setNumPieceCnt(String numPieceCnt) {
            this.numPieceCnt = numPieceCnt;
        }
     
        public String getNomNomCnt() {
            return this.nomNomCnt;
        }
     
        public void setNomNomCnt(String nomNomCnt) {
            this.nomNomCnt = nomNomCnt;
        }
     
        public String getNomPreCnt() {
            return this.nomPreCnt;
        }
     
        public void setNomPreCnt(String nomPreCnt) {
            this.nomPreCnt = nomPreCnt;
        }
     
        public String getAdrAdrCnt() {
            return this.adrAdrCnt;
        }
     
        public void setAdrAdrCnt(String adrAdrCnt) {
            this.adrAdrCnt = adrAdrCnt;
        }
     
        public String getNumGsmCnt() {
            return this.numGsmCnt;
        }
     
        public void setNumGsmCnt(String numGsmCnt) {
            this.numGsmCnt = numGsmCnt;
        }
     
        public String getCodTpceCnt() {
            return this.codTpceCnt;
        }
     
        public void setCodTpceCnt(String codTpceCnt) {
            this.codTpceCnt = codTpceCnt;
        }
    }
    la page est la suivante :
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
    <head>
    <title>Gestion</title>
    </head>
    <body>
    <ui:decorate template="../template/template.xhtml">
     
    <ui:define name="body">
     <h:form >
     
     <f:view>
     <div align="center">
     
        <rich:dataTable border="1" rules="all" value="#{Con.contact}" var="p">
     
        <h:column>
                <f:facet name="header">
                    <h:outputText value="NumeroPiece" />
                </f:facet>
                <h:outputText value="#{p.numPieceCnt}" />
            </h:column>
     
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Prénom" />
                </f:facet>
                <h:outputText value="#{p.nomPreCnt}" />
            </h:column>
     
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Nom" />
                </f:facet>
                <h:outputText value="#{p.nomNomCnt}" />
            </h:column>
     
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Adresse" />
                </f:facet>
                <h:outputText value="#{p.adrAdrCnt}" />
            </h:column>
     
     
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Gsm" />
                </f:facet>
                <h:outputText value="#{p.numGsmCnt}" />
            </h:column>
     
            <h:column>
                <f:facet name="header">
                    <h:outputText value="TypePiece" />
                </f:facet>
                <h:outputText value="#{p.codTpceCnt}" />
            </h:column>
     
    </rich:dataTable>
    </div>
    </f:view>
     
     
     </h:form>
     </ui:define>
     </ui:decorate>
     </body>
     </html>
    Quelqu'un saurait-il me dire d'où pourrait venir le problème ?

    Merci d'avance pour votre aide.

  2. #2
    Membre à l'essai
    Homme Profil pro
    Concepteur architecte en informatique
    Inscrit en
    Mai 2012
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Concepteur architecte en informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2012
    Messages : 5
    Par défaut
    salut,
    si je reprends ton code je ne vois pas l'injection du managed bean, je suppose qu'il est ds ton web.xml, c'est qd meme plus clair de l'injecter directement @ManagedBean.

    si l'injection est ok, ce serait egalement plus visible pour ns de voir comment tu te connectes à la base car rien ds ton code ne l'indique, ou est l'entityManager..., passe tu par un EJB, ou est son injection... ou directement ds le bean mais je ne vois pas l'EntityManagerFactory.
    je suppose que le prob se situe là...

  3. #3
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Par défaut
    Peut on voir ton faces-config.xml et ton web.xml?

  4. #4
    Membre éclairé
    Homme Profil pro
    Inscrit en
    Mai 2011
    Messages
    790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Mai 2011
    Messages : 790
    Par défaut
    Merci pour votre réponse au fait j'ai trouvé la solution j'ai mis

    private List<Contact> contact=new ArrayList<Contact>();
    et dans la methode getContact j'ai enlevé la conditionet ça marche ^^

    Maintenant je suis entrain de cherche comment trier ce dataTable et j'ai pas vraiment trouvé la solution

  5. #5
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Par défaut
    Citation Envoyé par ahmedpa Voir le message
    Merci pour votre réponse au fait j'ai trouvé la solution j'ai mis

    private List<Contact> contact=new ArrayList<Contact>();
    et dans la methode getContact j'ai enlevé la conditionet ça marche ^^

    Maintenant je suis entrain de cherche comment trier ce dataTable et j'ai pas vraiment trouvé la solution
    Je sais qu'on peut mettre l'attribut sur l'élément mais sur h:column je ne me souviens plus. Essaies voir et redis nous.

  6. #6
    Membre éclairé
    Homme Profil pro
    Inscrit en
    Mai 2011
    Messages
    790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Mai 2011
    Messages : 790
    Par défaut
    Sur h:column il n y a aucun changement sur la liste!!
    Je crois qu"il faut ajouter une methode qui permet de faire le tri non ?

  7. #7
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Par défaut
    Citation Envoyé par ahmedpa Voir le message
    Sur h:column il n y a aucun changement sur la liste!!
    Je crois qu"il faut ajouter une methode qui permet de faire le tri non ?
    Et pourquoi tu passerais pas en rich:column? puisque tu utilises déjà rich:datatable au lieu de h:datatable? il faut rester cohérent non.

  8. #8
    Membre éclairé
    Homme Profil pro
    Inscrit en
    Mai 2011
    Messages
    790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Mai 2011
    Messages : 790
    Par défaut
    ça marche pas aussi

  9. #9
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Par défaut
    Fais nous revoir ton code source.

Discussions similaires

  1. Problème avec une UDF
    Par kanmaber dans le forum Bases de données
    Réponses: 2
    Dernier message: 27/08/2004, 23h42
  2. [JBOSS] [Struts] Problème avec une application
    Par Tiercel dans le forum Wildfly/JBoss
    Réponses: 5
    Dernier message: 13/07/2004, 13h50
  3. Problème avec une instruction OUTER /Postgres
    Par Volcomix dans le forum Langage SQL
    Réponses: 14
    Dernier message: 21/04/2004, 16h56
  4. problème avec une requête imbriquée
    Par jaimepasteevy dans le forum Langage SQL
    Réponses: 13
    Dernier message: 05/12/2003, 10h29
  5. Problème avec une procédure stockée
    Par in dans le forum Langage SQL
    Réponses: 4
    Dernier message: 27/05/2003, 15h33

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