Here’s the idea to sort a JSF dataTable list : 1. Column Header Put a commandLink in the column header, if this link is clicked, sort the dataTable list. <h:column> <f:facet name="header"> <h:commandLink action="#{order.sortByOrderNo}"> Order No </h:commandLink> </f:facet> #{o.orderNo} </h:column> 2. Implementation In the managed bean, uses Collections.sort() and custom comparator to sort the list. […]

Read more JSF 2 dataTable sorting example

This example is enhancing the previous JSF 2 dataTable example, by adding a “delete” function to delete the row in dataTable. Delete Concept The overall concept is quite simple : 1. Assign a “Delete” link to the end of each row. //… <h:dataTable value="#{order.orderList}" var="o"> <h:column> <f:facet name="header">Action</f:facet> <h:commandLink value="Delete" action="#{order.deleteAction(o)}" /> </h:column> 2. If […]

Read more How to delete row in JSF dataTable

This example is enhancing previous delete dataTable row example, by adding a “add” function to add a row in dataTable. Here’s a JSF 2.0 example to show you how to add a row in dataTable. 1. Managed Bean A managed bean named “order”, self-explanatory. package com.mkyong; import java.io.Serializable; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import […]

Read more How to add row in JSF dataTable

In JSF, “h:dataTable” tag is used to display data in a HTML table format. The following JSF 2.0 example show you how to use “h:dataTable” tag to loop over an array of “order” object, and display it in a HTML table format. 1. Project Folder Project folder structure of this example. 2. Managed bean A […]

Read more JSF 2 dataTable example