aspose file tools*
The moose likes JSF and the fly likes Broswer back button not refreshing. JSF 1.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Broswer back button not refreshing. JSF 1.1" Watch "Broswer back button not refreshing. JSF 1.1" New topic
Author

Broswer back button not refreshing. JSF 1.1

shannon rocks
Greenhorn

Joined: Nov 20, 2007
Posts: 7
Hi am working on a seam based application that uses JSF 1.1, ajax4jsf, hibernate and ejb3.0. Well this is my problem. I have this homePage which has 2 section. 1st section is a selection area where you can provide the selection criteria. The second section is a list which is entirly an ajax component. The list refreshes based on the selection. The list has an editable column for status and the values can be selected from a dropdown. (new, pending, complete, canceled). Also, the list has a column that is a link for the item details.

Say i log into my homePage and i provide my selection criteria and i get a list from the server and its got 4 items with each ones status as new. Now i click on item one which will take me to itemOneDetails page. I have a link in this page that will open a pdf report on a new window. I close this pdf window and from the itemOneDetails page i click the browser back button.

My requirement: the homePage with previous selection should be displayed but the itemOne status in the list should have changed from new to pending.

Whast happening: the homePAge is shown with previous selection and the list is also same but the colum with status remains as new only. I need to exclusively click on the search button on the homePage to refresh the list.

I tried disabling caching. I tried playing around with the STATE_SAVING_METHOD in web.xml etc. Am not able to refresh this list whatsoever.

Can someone help me resolve this issue as its really critical that i get this done ASAP.

Thanks in advance.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
This is the right behavior. Back button works from the browser cache. Suppose if you would be able to disable the browser cache then you may get the status right but not the selection. Hence, best thing is to not rely on the browser back button and give a custom back button on that page. Which would make a new request and return a current status with a particular records selected.

I hope you get the point.
shannon rocks
Greenhorn

Joined: Nov 20, 2007
Posts: 7
I do understand what your are pointing out. I have homePage link on the top navigation bar but users are so used to browser back button. I would need to achieve the desired requirement even on back button click.

I was searching all over the net today and could find a way in which the ajax caching can be avoided. Please find the code below. but i really dont know how to integrate this with my seam jsf ajax .xhtml code.

function xmlLoader(uri)
{
var request;
if(window.XMLHttpRequest)
{
request = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
request = new ActiveXObject("MSXML2.XMLHTTP");
}
var timestamp = new Date();
var uniqueURI = uri+ (uri.indexOf("?") > 0 ? "&" : "?")+ "timestamp="+ timestamp.getTime();
request.onreadystatechange = callbackMethod;
request.open("GET", uniqueURI, true);
request.send(null);

}

Am also considering calling a javascript which would look at a hidden variable using document.getElementById function to call the backing bean method. But rendered jsf page does not have the id as you set on the xhtml. so getElementById does not work? Even if i hack this part, how do i call the backing bean method directly from the javascript.

Looking forward for the best way possible to solve this problem in hand.

thanks.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Its not something you can do on the back button click. It would be an AJAX call to the server to get the current state. Back button would not request the server in that manner. You can make a new request to the server by disabling the browser cache, it would be a normal request not asynchronous. However, as I said earlier that, then you may get the status from the server but there would be no way to keep that particular object selected. You can use some trick at the back-end to decide which one should be displayed as selected, may be by keeping record of recent actions or some other tricky way.

On the other hand, in order to achieve this you may consider to refresh that particular part of your page in a specific amount of time to check the status from server using an AJAX call.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Broswer back button not refreshing. JSF 1.1