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 .