Basically there are couple pages which use the same custom controller (no extensions), it's kinda wizard.

When navigating between pages, i.e. clicking next/previous buttons, view state is preserved, everything works as expected. But for some reason after every click url in the browser is changed.

That's why we have an issue when user click browser's refresh button in the middle of the wizard, it just tries to refresh bad url. And yes, set redirect is set to false and we are using the same controller for all wizard pages (double checked).

Maybe someone from the community has already encountered with such problem (or maybe even solved it). Any help would be appreciated how to keep the same url in browser.

Thanks in advance.

  • Are you using multiple visualforce and one controller ? – Jitendra Zaa May 16 '15 at 19:51
  • Yep, one controller and many pages. – wesaw May 16 '15 at 20:39
  • In that case i am afraid if you will find any working solution, if it has different VF then URL will be changed. – Jitendra Zaa May 16 '15 at 20:41
  • That's kinda strange. I thought that server-side redirect should work without changing browser's url (that's why it's server-side, i.e. opposite to client-side) – wesaw May 16 '15 at 20:44
  • 1
    It works fine when done correctly so you are doing something not correct. In order to understand that something you would be better served to post the relevant code in your questions. – Eric May 18 '15 at 2:16

I don't know how to do it on the platform, but using javascript, you could leverage the History API (https://developer.mozilla.org/en-US/docs/Web/API/History) to rewrite the URL.

Something like this

window.history.replaceState({}, document.title, '/url');

I have a similar application where I used 2 VF pages and same controller. SetRedirect works just fine for me.
Hope you are doing as mentioned below.

PageReference newPage = new PageReference('/apex/Page2');
 your logic...code...

 return newPage;

I just checked doing a refresh and the data on second page form is cleared but there is no bad url error.

Can you share any errors you find in logs/screen ?

Rgds, Dave


As I understand, when you hit refresh within any wizard step, system would ask you to re-submit the form, i.e. imitate last form post. This should not cause any issue, unless controller is handled properly.

Also, as wizard pages use same controller, they initialize only once. So, in order to maintain state of controller object, I would presume that any refresh should either be re-posting (by default done by browser) or you should add a button "Restart" to enable users to restart the wizard.

An additional approach that we had used was that we had a big wizard with lots of data to be populated in each step. So, we saved data in each page submit, this helped us in storing data half-way to avoid data loss and make pages lighter. Also, if user just selects the url and pastes it in different tab, it still works (normal wizards can fail, as they would not be usually equipped to initialize properly from intermediate steps)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.