PDA

View Full Version : browser's back button


thinkspace
Aug 11th, 2006, 03:53 AM
Hi all,

it's my first time here and i hope im on the right thread. i developed a search module using spring framework and some ajax using dwr framework. it works fine except the back and forward button of the browser. when i click next page on my paging it works as expected, then i click the button of the browser and i got Warning: Page has expired..... does anyone know how to handle this thing? some code snippets are greatly appreciated.

Tnx,
-think

EndlessWinter
Aug 11th, 2006, 04:52 AM
Try to search "Redirect after POST" pattern in google.
Or, make your page transitions (including form submits) to be GET requests.
I think dwr framework has nothing to do with your problem, because dwr requests don't go to the browser history

thinkspace
Aug 13th, 2006, 10:36 PM
hi EndlessWinter,

Thank you so much for your reply. I read you the info that you've given me about Redirect after POST, it's nice but i can't relate it. The Redirect after post will be implemented in the controller or in jsp page? Or can you please give an example code.

Tnx in advance!


Regards,
-think

EndlessWinter
Aug 14th, 2006, 05:10 AM
Can you provide the details of search form element from your page? Is it done via DWR, or Spring?

thinkspace
Aug 14th, 2006, 10:02 PM
Hi EndlessWinter,

i appreciate ur help. in my search it is mainly done using Spring. i used dwr for some actions in result page like saving a search for future use. the details are: in the result page the user can select a result and add to list which will pop up on the right side of the page and upon adding i dynamically created a hidden fields using javascript in the document since selected items can be 2 or more or hundreds is possible. the form will be submitted each time the user traverse to next/previous page and the previous selected items are retained. now, in my jsp i have a default:

<form name="advancedSearchForm" id="advancedSearchForm" method="post" action="<%=request.getContextPath()%>/jsp/search/saved-searches.vse">

but the action will change to "/jsp/search/advanced-search.vse" if the user traverse the page for more results.

any help and suggestion are greatly appreciated!

tnx,
-think

EndlessWinter
Aug 15th, 2006, 05:18 AM
Do you think it will hurt your app to change method="post" to method="get"?
If you insist to use POST, your saved-searches.vse should have a redirect view.

Something like:
1) POST to saved-searches.vse
2) controller run's search, puts results in the session
3) return new ModelAndView(new RedirectView("searchResults"))
4) searchResults uses session object to visualize the results

But switching to GET is much simpler :)

thinkspace
Aug 15th, 2006, 09:40 PM
Hi EndlessWinter,

i did follow ur suggestions and change form method to "get" of all jsp's involved in search and it works fine now.

Thank you so much!

Regards,
-think