Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic JSF navigation

 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • 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


 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
oops! Thanks Bauke.
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic