6/21/07

JSF code snippet: No data found message for a table

A short one: display a message when there's no results to display in the dataTable

< h:dataTable value="#{BackingBean.tableModel}"
... rest of the dataTable configuration
>
..... dataTable columns ...
< /h:dataTable>

< h:panelGrid width="100%" rendered="#{BackingBean.tableModel.rowCount == 0}">
< value="#{msgs.noResults}">
< /h:panelGrid>



The datatable will render only the column titles, and then the panel grid with the message will be rendered

UPDATE: I just noticed that while posting, the JSF tags got completely messed up, should be fixed now

No comments: