I tried to display the list of products using JSF but nothing is displayed the list is not empty is there is no error. here is the code of the xhtml page.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
</h:head>
<h:body>
<h:form>
<h:dataTable var="p" value="#{produitController.findAll()}">
<h:column>
<f:facet name="header">id</f:facet>
<h:outputText value="${p.id}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">name</f:facet>
<h:outputText value="${p.name}"></h:outputText>
</h:column></h:dataTable>
</h:form>
</h:body>
</html>
And this is class code:
@ManagedBean(name="produitController")
@SessionScoped
public class produitController
{private Produit produit=new Produit();
public String page()
{
return "page";
}
public Produit getProduit() {
return produit;
}
public void setProduit(Produit produit) {
this.produit = produit;
}
public List<Produit> findAll(){
List<Produit> listProduit=new ArrayList<Produit>();
listProduit.add(new Produit("1", "produit 1",1500, new Date()));
return listProduit;
}
}