unable to display data in datatable of jsf
I've the data(retrieved from database) in a list but when I use
`f:view><html>
<body>
<center>
<h:dataTable id="dt1" value="#{dataList.list}" var="item" >
&开发者_StackOverflow中文版lt;h:column>
<f:facet name="header">
<h:outputText value="Num" />
</f:facet>
<h:outputText style="" value="#{item.myNum}" ></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<h:outputText value="#{item.myName}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Country"/>
</f:facet>
<h:outputText value="#{item.myCountry}"></h:outputText>
</h:column>
</h:dataTable><br>
</center>
</body></html></f:view>`
it is displaying a blank data table.
It may sound trivial, but you need to add columns:
<h:dataTable id="dt1" value="#{dataList.list}" var="item">
<h:column>
<h:outputText value="#{item.myData}">
</h:column>
<h:column>
<h:outputText value="#{item.myOtherData}">
</h:column>
</h:dataTable>
the myData
and myOtherData
names must be members of the list element's underlying object.
UPDATE:
Here is a good tutorial for datatables. If you use JSF 2.0 you do not need to register the bean in faces-config.xml. Then you can use annotations.
精彩评论