DataTable Conditional Row Messages

You are viewing an old version (v. 4) of this page.
The latest version is v. 11, last edited on Nov 01, 2012 (view differences | )
<< View previous version | view page history | view next version >>

DataTable supports 'supplementary' rows rendered on a condition; either at particular interval, before or after a column-value grouping, on 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.

Normal Row

The normal row will contain the columns (in this sample, 1 column) & components nessescary to render our row objects.

<ace:column headerText="ID">
    <h:outputText id="idOutput" value="#{row.id}" binding="#{backing.idOutput}" />
</ace:column>

Supplementary Row

The supplementary row will contain the h:messages component needed to show the messages resulting from the compnents of our standard row.

<ace:row condition="predicate" predicate="#{backing.predicate}">
&nbsp;&nbsp; &nbsp;<ace:column>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; <h:messages for="idOutput" style="font-size: 10pt; color:red; margin: 0.3em 0 0.5em 0;"/>
&nbsp;&nbsp; &nbsp;</ace:column>
</ace:row>

Predicate Definition

The predicate is a function that is passed an object, 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 example of this fact, and references the iterative, data-bound outputText component of the row to use its clientId to find any attached messages.


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2017 ICEsoft Technologies Canada Corp.