aspose file tools
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 The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "if else in h:dataTable" Watch "if else in h:dataTable" New topic
Author

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="http://jy-s.com" target="_blank" rel="nofollow">http://jy-s.com</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
OR
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: if else in h:dataTable