Hi!
I'm new to
JSF and to experiment with JSF, and Rich Datatables I tried to create a dumb, simple project to output a simple datable with only one column.
Its so simple that it should work but its not, I cant get my datatable to iterate over my collection.
I have 2 classes :
<blockquote>
code:
<pre name="code" class="core">
package test;
import java.util.ArrayList;
import java.util.Collection;
public class TestBean {
private String nomTableau;
private Collection<Detail> listeDetails;
public TestBean(){
this.nomTableau = "Commmmoonn!!!";
this.listeDetails = new ArrayList<Detail>();
this.listeDetails.add(new Detail("detail 1"));
this.listeDetails.add(new Detail("detail 2"));
this.listeDetails.add(new Detail("detail 3"));
}
public Collection<Detail> getListeDetails() {
return listeDetails;
}
public void setListeDetails(Collection<Detail> listeDetails) {
this.listeDetails = listeDetails;
}
public String getNomTableau() {
return nomTableau;
}
public void setNomTableau(String nomTableau) {
this.nomTableau = nomTableau;
}
}</pre>
</blockquote>
And :
<blockquote>
code:
<pre name="code" class="core">
package test;
public class Detail {
private String detail;
public Detail(){
this.detail = "bidon";
}
public Detail(String detail){
this.detail = detail;
}
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
}
</pre>
</blockquote>
In faces-config.xml I put my TestBean class as bein managed :
<blockquote>
code:
<pre name="code" class="core">
<faces-config>
<managed-bean>
<managed-bean-name>testBean</managed-bean-name>
<managed-bean-class>test.TestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>
</pre>
</blockquote>
And finaly, I try to output the result in a
jsp file :
<blockquote>
code:
<pre name="code" class="core">
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<html>
<head>
<title>Simple Data Table</title>
</head>
<body>
<rich:dataTable id="laTable" var="item" value="#{testBean.listeDetails}" >
<rich:column>
<f:facet name="header">
<h:outputText value="#{testBean.nomTableau}" />
</f:facet>
<h:outputText value="#{item.nomDetail}" />
</rich:column>
</rich:dataTable>
</body>
</html>
</pre>
</blockquote>
The value of "testBean.nomTableau" is displayed but thats all. When I check the logs I always get the following output when I try to print the value of "item.nomDetail" :
<blockquote>
code:
<pre name="code" class="core">
(DEBUG) ValueBindingImpl : getValue(ref=item.nomDetail)
(DEBUG) ApplicationImpl : Couldn't find a factory for item
(DEBUG) VariableResolverImpl : resolveVariable: Resolved variable:null
(DEBUG) ValueBindingImpl : getValue Result:null
(DEBUG) ValueBindingImpl : -->Returning null
(DEBUG) HtmlBasicInputRenderer : component.getValue() returned null
(DEBUG) HtmlBasicRenderer : Value to be rendered null
</pre>
</blockquote>
Anybody have an idea of what I'm doing wrong?
Thank you!
Maxime