I am experiencing an odd behavior on my visual force pages and i would like to know if others have experienced this. I have a multistep wizard where several visual force pages use one controller. On the very first visual force page say /apex/vf1 there is a command link button which on clicking does some processing on the controller and does a page reference forward to vfpage2. At this point the vfpage2 gets loaded on the browser but the url still says /apex/vf1 on the browser. Now i hit next command link button on vfpage2 which does processing on the controller and does a page reference forward to vfpage3. Now vfpage 3 loads on the browser and the url changes to /apex/vfpage2. So the url on the browser changes one step after the page is loaded and the user clicks a button on it. Can you guys explain why? My assumption is that the url should change on page on load on the browser..
I suspect the PageReference objects you are returning have
setRedirect as false. This is a server side redirect that preserves the wizard viewstate between post back requests and can only occur with a shared controller.
If setRedirect were true then a client side redirect would result in an HTTP GET request to the subsequent page and the URL would change. You would also lose any view state that had been accumulated.
When you perform subsequent POST requests back on a page it advances to the previous visualforce page as that is where the POST is being sent to.
- GET request to /apex/vf1
- COMMAND button performs a POST to /apex/vf1
Salesforce responds with the new HTML, still on /apex/vf1. The new content will send a POST request to /apex/vf2
- COMMAND button performs a POST to /apex/vf2, Browser URL changes to /apex/vf2.
Salesforce responds with the new HTML that will send a POST request to /apex/vf3