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 :

[JSF] Debutant rich:dataTable


Sujet :

JSF Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    411
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 411
    Par défaut [JSF] Debutant rich:dataTable
    Bonjour,

    Je débute dans les EJB3 et le JSF.

    J'essaye donc de créer un dataTable voici mon code

    Ma page jsf:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
             <h:form>
            <rich:dataTable value="#{ImportBean.jobs}" var="jobs" width="300px">
                <f:facet name="header">
                    <h:outputText value="Tableau des logs"/>
                </f:facet>
                <rich:column sortBy="#{jobs.nom}">
                    <f:facet name="header">
                        <h:outputText value="Nom"/>
                    </f:facet>
                    <h:outputText value="#{jobs.nom}"/>
                </rich:column>
                <rich:column sortBy="#{jobs.nom}">
                    <f:facet name="header">
                        <h:outputText value="Debut"/>
                    </f:facet>
                    <h:outputText value="#{jobs.nom}"/>
                </rich:column>
                <rich:column sortBy="#{jobs.nom}">
                    <f:facet name="header">
                        <h:outputText value="Fin"/>
                    </f:facet>
                    <h:outputText value="#{jobs.nom}"/>
                </rich:column>
            </rich:dataTable>
        </h:form>
    Ma class bean:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
     
    public class JobsBean {
    private List<Job>  jobs;
     
        @EJB
        private LogDstageSessionBeanLocal<Job> ufl;
     
     public void ImportBean() {
             List<Job> j = new ArrayList<Job>();
             //imports=ufl.findImports();
             j.add(new Job(1,"job 1"));
             j.add(new Job(2,"job 2"));
             //this.jobs=new ListDataModel(j);
             //return (new ListDataModel(imports));
         }
     
     public List<Job> getJobs(){
         List<Job> j = new ArrayList<Job>();
             //jobs=ufl.findjobs();
             j.add(new Job(1,"job 1"));
             j.add(new Job(2,"job 2"));
             j.add(new Job(3,"job 3"));
             j.add(new Job(4,"job 4"));
             j.add(new Job(5,"job 5"));
             this.jobs=j;
        return jobs;
      }
     
    }
    Ma classe session:
    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
    @Stateless
    public class LogDstageSessionBean<T> implements LogDstageSessionBeanLocal<T> {
        @PersistenceContext(unitName="LogDstage-ejbPU")
        EntityManager em;
        public T create(T entity) {
            em.persist(entity);
            return entity;
        }
     
        public T edit(T entity) {
            return em.merge(entity);
        }
     
        public void remove(T entity) {
            T entityToDel=em.merge(entity);
            em.remove(entityToDel);
        }
     
        public List<T> find(Class<T> entityDescription) {
            return em.createQuery("select object(o) from "+ entityDescription.getSimpleName() + "as o").getResultList();
     
        }
     
        public T findByPrimaryKey(Class<T> entityDescription, Object id){
            return em.find(entityDescription,id);
        }
     
        public User getUserWithLoginAndPassword(String login, String password)
        {
            Query q = em.createQuery("select object(o) from User as o where o.login= :id");
            q.setParameter("id",login);
            List<User> l=q.getResultList();
            if(l.size()>0)
            {
                User user = l.get(0);
                if(user.getMdp().equals(password)  || true)
                {
                    return user;
                }
            }
            return null;
            /*User u=new User(1, login, password, 0, "tttt");
            return u;*/
        }
    Cette classe m'a était conseil pour ne pas avoir plusieurs classes sessions!!

    Et ma classe entity Job:
    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
    @Entity
    @Table(name = "job")
    @NamedQueries({@NamedQuery(name = "Job.findAll", query = "SELECT j FROM Job j")})
    public class Job implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Basic(optional = false)
        @Column(name = "idjob")
        private Integer idjob;
        @Basic(optional = false)
        @Column(name = "nom")
        private String nom;
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "job")
        private Collection<UserJobWar> userJobWarCollection;
        @JoinColumn(name = "log_idlog", referencedColumnName = "idlog")
        @ManyToOne(optional = false)
        private FicLog logIdlog;
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "jobIdjob")
        private Collection<Import> importCollection;
     
        public Job() {
        }
     
        public Job(Integer idjob) {
            this.idjob = idjob;
        }
     
        public Job(Integer idjob, String nom) {
            this.idjob = idjob;
            this.nom = nom;
        }
     
        public Integer getIdjob() {
            return idjob;
        }
     
        public void setIdjob(Integer idjob) {
            this.idjob = idjob;
        }
     
        public String getNom() {
            return nom;
        }
     
        public void setNom(String nom) {
            this.nom = nom;
        }
     
        public Collection<UserJobWar> getUserJobWarCollection() {
            return userJobWarCollection;
        }
     
        public void setUserJobWarCollection(Collection<UserJobWar> userJobWarCollection) {
            this.userJobWarCollection = userJobWarCollection;
        }
     
        public FicLog getLogIdlog() {
            return logIdlog;
        }
     
        public void setLogIdlog(FicLog logIdlog) {
            this.logIdlog = logIdlog;
        }
     
        public Collection<Import> getImportCollection() {
            return importCollection;
        }
     
        public void setImportCollection(Collection<Import> importCollection) {
            this.importCollection = importCollection;
        }
     
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (idjob != null ? idjob.hashCode() : 0);
            return hash;
        }
     
        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof Job)) {
                return false;
            }
            Job other = (Job) object;
            if ((this.idjob == null && other.idjob != null) || (this.idjob != null && !this.idjob.equals(other.idjob))) {
                return false;
            }
            return true;
        }
     
        @Override
        public String toString() {
            return "com.eqx.logdstage.ejb3.entity.Job[idjob=" + idjob + "]";
        }
     
    }

    Lorsque j'essaye d'afficher ma page jsf je ne vois uniquement l'entête du tableau et donc pas les données. je cherche désespérément depuis vendredi la solution .

  2. #2
    Rédacteur

    Profil pro
    Inscrit en
    Juin 2003
    Messages
    4 184
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 4 184
    Par défaut
    vérifie en debug, la liste doit être vide.

  3. #3
    Membre éclairé
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    411
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 411
    Par défaut
    J'ai jamais utilisé le mode débug. J'ai essayé de mettre des breakpoint sur certaine ligne du rich:dataTable et quand je lance sur la fenêtre débug il y a plein de timer ou thread qui sont en attente ou en sommeil.
    ça m'aide pas trop. Peut tu me dire sur quelle ligne je doit mettre le breakpoint?

  4. #4
    Rédacteur

    Profil pro
    Inscrit en
    Juin 2003
    Messages
    4 184
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 4 184
    Par défaut
    dans le getter de la liste d'objets qui doit d'afficher dans la dataTable, pas dans le fichier jsp ou xhtml.

  5. #5
    Membre éclairé
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    411
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 411
    Par défaut
    Ok j'ai mis un getter sur cette fonction
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    public List<Job> getJobs(){
         List<Job> j = new ArrayList<Job>();
             //jobs=ufl.findjobs();
    ici->   j.add(new Job(1,"job 1"));
             j.add(new Job(2,"job 2"));
             j.add(new Job(3,"job 3"));
             j.add(new Job(4,"job 4"));
             j.add(new Job(5,"job 5"));
             this.jobs=j;
        return jobs;
      }
    Mais je comprends pas trop comment fonctionne le mode débug .

  6. #6
    Rédacteur

    Profil pro
    Inscrit en
    Juin 2003
    Messages
    4 184
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 4 184
    Par défaut
    si tu utilise Eclipse: F6 pour le pas à pas et F5 pour passer.
    Pourquoi tu ne mets pas le point d'arrêt à la dernière ligne.
    ton bean est session/request?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. JSF rich dataTable probleme de valeur
    Par Pirion dans le forum JSF
    Réponses: 4
    Dernier message: 09/06/2009, 16h20
  2. jsf rich:dataTable (problème avec getRowData)
    Par salimrok dans le forum JSF
    Réponses: 4
    Dernier message: 28/01/2009, 13h57
  3. [JSF][Debutant] SelectOneMenu
    Par faya972 dans le forum JSF
    Réponses: 6
    Dernier message: 13/05/2008, 18h18
  4. debutant en DataTable en jsf
    Par mans27 dans le forum JSF
    Réponses: 1
    Dernier message: 30/03/2007, 18h12
  5. [jsf-debutant] Qustion !!
    Par maximus001ma dans le forum JSF
    Réponses: 3
    Dernier message: 04/07/2006, 13h00

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