DataTable supports 'supplementary' rows rendered on a condition; either at particular interval, before or after a column-value grouping, or based on the result of an application defined conditon. This tutorial demonstrates the last technique, defining a condition that renders the supplementary row following a row whose h:outputText component has an attached FacesMessage.
We will cover the definition of the 'normal' row, 'supplementary' row and the predicate that determines row rendering based on FacesMessage presence.
The attachement of the FacesMessage to the component is merely to demonstrate the technique, and will not be covered in detail.
The normal row will contain the columns (in this sample, 1 column) & components nessescary to render our row objects. Note the binding. This is used later to retrieve the clientId during predicate evaluation, to check for associated FacesMessages.
The supplementary row will contain the h:messages component needed to show the messages resulting from the components of our standard row. The for property of the message component should be the client id of the normal row component that may have attached messages. One h:message component is required per component. If h:messages doesn't have 'for' defined, it prints the messages of all components in this page.
The predicate is an object with a single method, with a single object argument, in this case an integer row index, and determines if the row satisfies the conditon. The predicate is also evaluted following iteration to the row index in question, so the request context variables are in sync with the correct row object. The predicate in this example takes advantage of this fact, and references the iterative, data-bound outputText component of the row to use its correctly indexed clientId to find any attached messages.
WIth these components, a whole range of row-level summary or description behaviours are possible, we hope this tutorial has given you some ideas of your own!