The problem is that you are making a POST request to return the grid, which is fundamentally a GET action. When you use the browser back button to try to return to a page that was requested via POST, the browser will typically display a message indicating the page has expired (because responses to POST requests are not cacheable) and make you jump through some hoops to re-submit the request (this is because POST requests generally result in changes to resources, so it is assumed you do not want to re-submit and repeatedly make the same change simply by hitting the back button).
In this case, a better approach would be to make a GET request by changing the form method to "get". However, that will put "var1" and "testval" into the query string of the /default/results URL, which you may not want. As an alternative, you can submit the form back to the index function and then have the index function redirect to the results function after saving "var1" to the session: In index.html, change the form method to "get": <form enctype="multipart/form-data" method="get" action='#' > In the controller: def index(): if request.vars: if request.vars.testval and session.var1: del session.var1 if request.vars.var1 and not session.var1: session.var1 = request.vars.var1 redirect(URL('default', 'results')) return dict(message='Hello World') def results(): grid = {} if session.var1: query = (db.Category.Name==session.var1) grid = SQLFORM.grid(query=query) return dict(grid=grid) Anthony On Saturday, August 30, 2014 1:14:25 AM UTC-4, Sarbjit wrote: > > Hi Anthony, > > I am able to reproduce this problem in a small app (tested on windows - > 2.9.5). > > *MODEL:* > > db.define_table('Category', > Field('Name'), > Field('SubCategoryName')) > > # Insert test data > > if db(db.Category.id>0).count() == 0: > db.Category.insert(Name='PC',SubCategoryName='Intel') > db.Category.insert(Name='PC',SubCategoryName='AMD') > db.Category.insert(Name='SmartPhone',SubCategoryName='Apple') > db.Category.insert(Name='SmartPhone',SubCategoryName='HTC') > db.Category.insert(Name='SmartPhone',SubCategoryName='Google') > > *CONTROLLER:* > > def index(): > response.flash = T("Welcome to web2py!") > return dict(message=T('Hello World')) > > def results(): > if (request.vars.testval and session.var1): > try: > del session.var1 > except Exception : pass > if (request.vars.var1) and (not session.var1): > session.var1 = request.vars.var1 > grid = {} > if session.var1: > query = (db.Category.Name==session.var1) > grid = SQLFORM.grid(query=query) > return dict(grid=grid) > > *VIEWS:* > > *results.html* > > {{extend 'layout.html'}} > {{=grid}} > > *index.html* > > {{extend 'layout.html'}} > <form enctype="multipart/form-data" method="post" > action={{=URL('default','results')}} > > <select name="var1"> > <option value="PC">PC</option> > <option value="SmartPhone">Smart Phone</option> > </select> > <input type="submit" value='Submit'> > <input type="hidden" name="testval" value="test" /> > </form> > > *Steps to reproduce the problem :-* > > 1. Select any value from the drop down and hit submit button. > 2. Select any GRID row and click on View > 3. Use Browser Back button -> Document will expire, you have to refresh to > get the results back (Tried on Chrome/Firefox) > 4. Repeat Step2 > 5. Now instead of using Browser back button, use GRID embedded back button. > 6. Now repeating step 2-3 won't cause any problem (document won't expire) > until the new selection is made from the selection drop down. > > Please suggest something to resolve this problem. > > Thanks > Sarbjit > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.