File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Need to force JSF page to get latest data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Need to force JSF page to get latest data" Watch "Need to force JSF page to get latest data" New topic
Author

Need to force JSF page to get latest data

John Storta Jr.
Greenhorn

Joined: Jul 26, 2009
Posts: 29
I have a JSF page with a DataTable. It is bound to a backing bean and provides a report from a MySQL table.

Everything works great. I get the output. I can click on a row to edit it. I can save the changes. But, when I go back to, or reload, the page with the DataTable output, I get the same values that were there originally, regardless of what edits I made. I view the Tomcat log and I can see that no new request is being sent to the database for updated information. The only way for the page to re-read the database is to restart the web server.

The data is apparently being cached somewhere, but I cannot figure out where. My gut tells me that the browser is caching it. I had a similar problem with some servlets and I had to add a time-stamp parameter to force the servlet to run anew each time. I have not figured out how to do this in JSF and before I do I want to make sure there is not some flag built into JSF that I can set to accomplish the same thing.

When I load the JSF page with the DataTable, I want it to go and get the latest data from the database every time. I do not want the data
to ever come from a cache. Likewise, I need to make sure that browsers do not cache the data and always request the latest.

Any thoughts on how to force this?

Thanks,
John S.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Howdy, Greenhorn!

Is there any way the data is being cached in the HttpSession? Could you change the scope of a bean from session to request to address the issue?

Have you tried with different browsers?

Just some ideas.

-Cameron McKenzie
John Storta Jr.
Greenhorn

Joined: Jul 26, 2009
Posts: 29
I tried setting the bean to be a request bean, but then I lose some of the binding necessary to add and delete records.

I have the same results in FireFox and IE6. I was going to test other browsers, but I have not yet figured out how to get the later versions to run on Ubuntu.

Thanks,
John S.
John Storta Jr.
Greenhorn

Joined: Jul 26, 2009
Posts: 29
After doing more testing with using a request scoped bean, I realized that the issues I was having with the data binding was actually a result of me not coding it properly -- not really a surprise there.

I fixed my code and changed the managed-bean to have 'request' scope and now my page with the DataTable always requests the latest data every time.


Thanks for the advice. It really got me heading in the right direction.


John S.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Thanks for the post-back.

Mastering Java technology is always fraught with tough problems. Don't let it get you discouraged.

Regards!

-Cameron McKenzie
 
wood burning stoves
 
subject: Need to force JSF page to get latest data