h:column |
|
The column tag renders a single column of data within a data table
component. A column of data can contain any number of rows depending on the
length of the array or list associated with the data table. See the dataTable
tag for more information.
JSF Example
<!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:h="http://java.sun.com/jsf/html">
<h:head/>
<body>
<h:dataTable value="#{itemBean.items}" var="item" border="1" cellspacing="2">
<h:column>
<h:outputText value="#{item}" />
</h:column>
</h:dataTable>
</body>
</html>
This example was formatted by JSFToolbox for Dreamweaver.
Java Code
package com.mycompany;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class ItemBean {
public List<string> getItems() {
List<string> items = new ArrayList<string>();
items.add("Apples");
items.add("Oranges");
items.add("Bananas");
return items;
}
}
Rendered Output
HTML Output
<table border="1" cellspacing="2">
<tbody>
<tr>
<td>Apples</td>
</tr>
<tr>
<td>Oranges</td>
</tr>
<tr>
<td>Bananas</td>
</tr>
</tbody>
</table>
|