Find your content:

Search form

You are here

Visualforce Page Loses Search Parameters when Going Back from Detail

 
Share

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.


Attribution to: Caspar Harmer

Possible Suggestion/Solution #1

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.


Attribution to: Matt Lacey

Possible Suggestion/Solution #2

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

Attribution to: Sergej Utko
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/5316

My Block Status

My Block Content