Displaying a list collection of objects
For CRUD examples, we are often faced with the practical problem of displaying the data in the application in a meaningful context that the user can understand. One of the easiest ways is to just print out a list of items for the fairly simple data. Another way is to display a tabular view of the data. There are other solutions worthy of consideration if your data is a tree structure or a graph.
For our case, we will choose the second path and display the list of contact details in a table. In JSF, we can use the <h:dataTable>
HTML component. This custom tag iterates over each object in the list and displays the specified values. The <h:dataTable>
component is a very powerful and flexible tag because the Java web engineer can configure it in order to render the custom styles in a variety of layouts.
Let's take a look at another JSF Facelet view, index.html
, in the jsf-crud
project. As a reminder, we are using Bootstrap CSS to style. Now,...