Jakarta EE 10 Faces 4.0 HtmlDataTable

18 views Asked by At

Where can I find sample code on how to implement a Jakarta Faces 4.0 HtmlDataTable? How do I bind the data to the HtmlDataTable and how do I bind the columns to an HtmlColumn?

This is the code I have so far:

private void createTable() {
    HtmlDataTable dataTable = new HtmlDataTable();
    dataTable.setValue("customerBean.customerList()");
    dataTable.setVar("customer");
    dataTable.getChildren().add(createColumn(dataTable, "Customer Number", "customerNumber"));
    dataTable.getChildren().add(createColumn(dataTable, "Customer Name", "customerName"));
    doc.add(dataTable);
}

private HtmlColumn createColumn(HtmlDataTable dataTable, String columnTitle) {
    HtmlOutputText header = new HtmlOutputText();
    header.setValue(columnTitle);
    HtmlColumn htmlColumn = new HtmlColumn();
    htmlColumn.setHeader(header);
    return htmlColumn;
}
0

There are 0 answers