Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if else in h:dataTable

 
Jolie Lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic