Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
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. –  CaspNZ Dec 12 '12 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. –  LaceySnr Dec 12 '12 at 11:02
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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