File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes if else in h:dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "if else in h:dataTable" Watch "if else in h:dataTable" New topic

if else in h:dataTable

Jolie Lee
Ranch Hand

Joined: May 08, 2005
Posts: 87
Hi, i use dataTable for looping a list of search results.

when the size of the result is 0, i want it to show a mesg "No record found" and at the same time i want the column header to be shown. How do i do that?

this is my dataTable:

Jys<br /><a href="" target="_blank" rel="nofollow"></a><br /> <br />Trying my very best to learn java, please forgive me if i'm asking some really stupid questions.
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Either customize the renderer
simple when the datatble record size is zero in COLLECTION_OBJECT, add an empty row in the COLLECTION_OBJECT inside the getter method of dataTable and set the text to "No records found" to any of the column property.

- Varun
Kevin Galligan
Ranch Hand

Joined: Aug 10, 2005
Posts: 70

However, if you are only displaying rows, and the page is simple, I think you could get away with using the jstl tags to test for length. This tends to not be recommended, however.
I agree. Here's the link:
subject: if else in h:dataTable
It's not a secret anymore!