3

I am building a Visualforce search page with results in a list format. When a user clicks a result, they are taken to a detail page for that record.

However, when they hit the back button on their browser, all their search results are lost and they get a fresh search page, which requires them to re-do their search to get their results back. Users are not happy!

I have been investigating options and have come up with these: I have a tricky problem - back button losing context and search parameters (as is common in salesforce ajax loaded pages) Do you have any ideas on how to solve?

Current possible solutions are:

  • Rewrite the url in the list view (which necessitates a page reload on search as IE9 is being used)
  • Save the search parameters in a session object in SF (hard to determine wether to load the session variables though)
  • Use Ajax to swap in a detail component, in place of the list view component (whilst keeping the main page untouched)
  • Open in a new tab.
  • Open using a popup.

My questions is this: Are there better options available? If so, I'd love to be illuminated.

2
  • This might be just a suggestion, but why not open the result in a new tab?
    – AslamK
    Nov 25, 2014 at 14:56
  • You are right - it is a suggestion - One that I've already considered in the above question. Nov 25, 2014 at 17:53

2 Answers 2

3

Personally I'd load the detail on the same page using ajax to keep it all in one place and easy to use, plus easier to code and maybe more stable, all you'd need is an <apex:outputPanel> or similar which wraps an <apex:detail> tag and you should be good.

However, if you really want to navigate to the other page and then back again you could serialise the search parameters and pass them through using the retURL parameter when you call the detail page. Then when your page loads and that parameter is present you could parse it and perform the relevant search.

2
  • So, do you mean that from the list view, I should add the retUrl parameter - I think I don't quite understand the significance of this parameter - is it processed by the SF rendering engine in such a way that it will become the URL that the back button goes to or do I have to do something? - Good answer btw, I've given it an upvote for now. Dec 12, 2012 at 8:48
  • Yep that's pretty much it, you'll see it used on a lot of pages, for instance when you create a new, or edit, a record—it's used to send the user to the correct location if they cancel an action most of the time.
    – Matt Lacey
    Dec 12, 2012 at 11:02
0

Do you have two pages?

  • If yes: check whether you button action method (PageReference i guess) don't have setRedirect(true)

If you have two panels (form mask and detail output):

  • If you have two panels - check that the button have reRender param set. Without that your page will be just reloaded after clicking on the button

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .