aspose file tools*
The moose likes JSF and the fly likes dynamic JSF navigation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "dynamic JSF navigation" Watch "dynamic JSF navigation" New topic
Author

dynamic JSF navigation

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
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

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Jan 13, 2008
Posts: 242
oops! Thanks Bauke.
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
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

Joined: Oct 08, 2006
Posts: 2458
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic JSF navigation
 
Similar Threads
A Very little problem in h:dataTable implementation
How to display contents of JList or drop down list?
<rich:tree> and database
I need to set <s:property> value in the action class
JSF ArralyList rendering to Target page is throwing Class Cast Exception