+ Start a Discussion

Facing error message while refreshing the page

Hi ,


In some of the browsers we are getting error message : 'To display the webpage again , the web browser needs to resend the information you've previously submitted'. This error is called when i am trying to redirect to another VF page, where the page gets refreshed. The code which i have used for refresh is "oncomplete="top.location.reload(true);".


Can anyone help me on this? Thank!

Imran MohammedImran Mohammed

Did you try window.parent.location.href = window.parent.location.href ?

And in which browsers are you getting this error message.


This is standard browser behaviour.  I'm assuming you have navigated to the page by submitting a form of data back to the server.  Essentially your javascript is the same as clicking the refresh button on the browser, which results in the form bring resubmitted.  The browser warns you that this is going to happen in case you were carrying out a purchase or similar.


Hi, Thanks for the response. I am using IE6 and i do not see this error, also i tried with IE7 and IE8 and it seems to be working fine. But i do not understand why is this error coming with few clients of our clients system. Even they are using IE6. what can i do to remove this error message and redirect the page directly to the parent window.? I have a 'back; button which redirects to the parent page and on click of this they are getting teh error. Can you share some of your views?


Also on the error message we have two button 'Retry'  and 'Cancel'. On click of both these buttons the i return the same page. Here is the code i used


 <apex:pageBlockButtons >
                <apex:commandButton action="{!back}" value="Back" oncomplete="top.location.reload(true);"/>
               <!-- <apex:commandButton action="{!save}" value="Save Selected" onclick="closewindow()"/> -->
                <apex:commandButton action="{!save}" value="Save Selected" rerender="c" oncomplete="top.location.reload(true);"/>
            <apex:pageMessages />


This doesn't look like the best way to do things.  Rather than rerendering part of the page and then reloading the window, why don't you let the controller specify the page reference to go to? 


Actually i have just declared a variable as 'c' for rendering , even if that is not there it doesnt matter. i apologize if that might have confused you. I can reference the page through the controller but the values saved wont be reflected on the parent page, tats the reason i am trying to refresh the page. Please let me know if i am not clear anywhere so that i can correct myself. Thanks!


Ah - so is this a visualforce section in a standard record view?


I have a VF page which displays some values with search functionality.


Delete functionality link  - Below is a section on the same page where in it displays existing records related a item with a remove command link. Here user can delete a record on click of command link . I am refreshing this page once he clicks the remove link so that the user can no longer see the deleted record.


See selected button - After displaying the search values with checkboxes we have a see selected button , onclick of this it redirects to another page where the page shows only selected values of the previous page.Here user can save the selected values or go back to previous page. After saving the selected records i am redirecting to the parent page and in the below section i need to show the selected values too. For this purpose i am refreshing the parent page to get the selected values. Here is where they are facing the error message.




For the delete functionality, you should just be able to return null from your action method that is carrying out the delete - that will cause the page to be refreshed.


I want to check I understand the "see selected" button functionality. The user clicks a button to see the record details and then they are taken to another page to view/edit the data.  Once they have done this you send them back to the main page.  If that is the case, I don't see any reason why you wouldn't use the action method that is carrying out the save to return the redirect.


Hi Bob,


I dint get your point.? did you mean i shoudnt have used the action method? is there any other way for this? Thanks!


The point I'm trying to make (badly, obviously!) is that its best to let the controller decide where the browser user should be redirected to, rather than trying to manage it client side.  Its a lot cleaner that way as everything is centralised in one place.


When an action method is invoked, it returns a pagereference which tells the browser the page that should be displayed. So your save method from the edit page would return the pagereference for the related view page.


The only time you should need to resort to javascript to influence the browser is if you are in a visualforce page embedded in a standard page.