4 Replies Latest reply on Dec 20, 2017 12:06 PM by Charlie Arehart

    Cfsearch empty result when user go.back

    Verrückter Level 1

      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>

        • 1. Re: Cfsearch empty result when user go.back
          Charlie Arehart Adobe Community Professional & MVP

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

          • 2. Re: Cfsearch empty result when user go.back
            Verrückter Level 1

            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>

            • 3. Re: Cfsearch empty result when user go.back
              Verrückter Level 1

              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.

              • 4. Re: Cfsearch empty result when user go.back
                Charlie Arehart Adobe Community Professional & MVP

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