Copy link to clipboard
Copied
I have a cfsearch working very good but when my user click on a result and hit the browser back button the search result is empty and my user have to do another search.
I would like the user who go back to see the result they had.
<cfif isdefined("form.recherche")>
<cfsearch name="searchResultsproduit" collection=" sextantProduitFR" criteria="#form.recherche#">
<cfsearch name="searchResults" collection=" sextantFR" criteria="#form.recherche#">
<!---<cfdump var="#searchResults#">--->
<cfoutput query="searchResultsproduit">
#custom2#
</cfoutput>
<cfoutput query="searchResults">
#custom2#
</cfoutput>
</cfif>
Copy link to clipboard
Copied
You say that when they back up, the results are "empty". Do you really mean that the page shows what it would show for the results, but there are no results?
Or do you mean that they get an error from the browser, and they have to reload the page? and THEN then do see the results?
If it's the second, then this is not a CFSEARCH problem, nor even a CF problem. It's a generic http problem (it would happen in any CF code and indeed any application server).
Why do I say that? I see that your code checks that there has been a form submission, and only does the search if it is. The problem is that according to the http spec, the results of a form post are NOT cached on the client (the browser), so when they hit the back button (to go "back" to that results page), the browser says the results can't be shown.
But if they refresh it then, the browser prompts if they want to re-send the form fields, and if they do, then you DO see the results. Is that what you are seeing?
Or do you mean it's the first problem above? If so, I would be surprised (given my explanation of the generic second problem).
Copy link to clipboard
Copied
Thanks for the answer Charlie,
First problem above, it don't ask to resend the form submission it only don't show any result, and even if I do a refresh manually it don't repost my form submission...
I did a work around, not the best solution but it work .... I store the form value in a session for 15 minutes and when the customer click back if my form data is not there and my session is still alive I just do the search with the value in the session ...
<cfif isdefined("form.recherche")>
<cfsearch name="searchResults" collection=" sextantFR" criteria="#form.recherche#">
<cfelseif isdefined("session.recherchecache")>
<cfsearch name="searchResults" collection=" sextantFR" criteria="#session.recherchecache#">
</cfif>
Copy link to clipboard
Copied
I have to say, that problem is with Google Chrome and IE,
Firefox show the previous page without asking anything
Safari ask to re-submit and show the result.
Copy link to clipboard
Copied
Interesting, and curious. Anyway, glad you got a solution.