• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

dynamic JSF navigation

 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I have developed a web interface to display from a databse. And it was useful to follow up an example from http://www.roseindia.net/jsf/data.shtml As my requirement is also very similar, I have finished the development. I have a very similar class as below which is used to display.



Now I would like to display a page when the result set is empty saying that no records are available. How do I do the modification. When there is any record, the above code works perfectly fine.

private List perInfoAll = new ArrayList();
.
.
.
return perInfoAll;


How do I achieve so that a string can be sent back so that I can display a page with "no records found". Thanks.

Regards


 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all: please read this. How to do it properly is covered here.

Back to your actual problem: just make use of the 'rendered' attribute of the component.

 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops! Thanks Bauke.
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bauke,

rendered property works fine but I have some doubts as well as problems.

case1: Without handling rendered: Works fine but did not handle the "no records found"



case2: With rendered property: Works fine if "No records are found" where as prints each record multiple times like 6 times.



Why is it printing one record multiple times.. Can't figure out the reason. Thanks.


 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have placed business/database logic inside the getter?? You shouldn´t do that! Getters can be called more than once in bean´s life. It makes no sense to hit the database on every getter call. Use constructor, initialization block, @PostConstruct or action methods for this. Or at least introduce lazy loading in the getter. Apart from that, it look like that you´re adding the results to an existing list everytime instead of recreating the list. That was also not so smart.
 
reply
    Bookmark Topic Watch Topic
  • New Topic