Quentin Renard
Quentin Renard

Reputation: 71

What is the best way to handle a session-persistant search form in a Spring web application?

I am looking for the best way to handle a session-persistant search form in a "shopping cart" like web application using the Spring MVC Framework.

I want to be able to navigate back to this search page, with last filters already set, from any other page in the application. This is not a master detail search results page, only a form with filters on a table of elements displayed underneath.

I can store my search filters in the user session, but what about multi-tabs navigation and browser back button handling ?

I also considered using Spring WebFlow to adress this.

Any suggestions ?

Upvotes: 0

Views: 476

Answers (1)

LaurentG
LaurentG

Reputation: 11727

That sounds like a good job for the conversation scope of Spring WebFlow. Objects which are stored in this scope are saved until the current flow is terminated (or by timeout). The usual way to use it in your case would be to create a new flow/conversation when the user starts browsing the webpage and saves the search parameters in the conversation scope. When going back to the search page later, the parameters are retrieved from this scope (if there are available).

The conversation scope solves the multi-tabs problem and avoid to have to send back to the server every time the data (as you would have to do if you only use the request scope).

Upvotes: 0

Related Questions