• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Cfsearch empty result when user go.back

New Here ,
Dec 20, 2017 Dec 20, 2017

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>

TOPICS
Advanced techniques

Views

371

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2017 Dec 20, 2017

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).


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2017 Dec 20, 2017

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2017 Dec 20, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

LATEST

Interesting, and curious. Anyway, glad you got a solution.


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation