[PrimeFaces] dataTable qui ne s'affiche pas
Salut,
j'essaye de tourner un exemple avec primesfaces3.3, jsf2.2, hibernate3, spring3 et tomcat7. je veux afficher un tableau contenant la liste des cours, j'ai deployé l'application dans tomcat7 il y a pas d'erreur mais rien ne s'affiche
mon bean:
Code:
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
| package com.jam.web;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.component.datatable.DataTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.jam.business.CourseService;
import com.jam.model.Course;
@SuppressWarnings("serial")
@ManagedBean(name="courseBean")
@SessionScoped
@Component("CourseBean")
@Scope("session")
public class CourseBean implements Serializable{
@Autowired
private static CourseService courseService;
private DataTable dataTable;
private List<Course> courseList;
public DataTable getDataTable() {
return dataTable;
}
public void setDataTable(DataTable dataTable) {
this.dataTable = dataTable;
}
@PostConstruct
public void init(){
courseList = courseService.findall();
}
public List<Course> getCourseList() {
courseList = courseService.findall();
return courseList;
}
public void setCourseList(List<Course> courseList) {
this.courseList = courseList;
}
} |
la page courselist.xhtml
Code:
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
| <!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:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:form>
<p:dataTable id="dataTable" value="#{courseBean.courseList}" var="course" border="1"
binding="#{courseBean.dataTable}">
<p:column headerText="Code">
<h:outputText value="#{course.courseCode}" />
</p:column>
<p:column headerText="Nom" >
<h:outputText value="#{course.courseName}" />
</p:column>
<p:column headerText="Durée">
<h:outputText value="#{course.courseLength}" />
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html> |
j'ai testé mon bean avec junit, courseList est bien remplie.
merci d'avance.