Hi all,
A Lift and Scala newbie here. I'm trying to build a pretty regular search form that lets you search for some data and displays the results in a paged table.
I have a snippet class with two methods: search and list. Search builds a POST-submitted form that collects query criteria from the user (currently a simple search string from a text box). List, on the other hand, fetches the data from the DB using the query criteria to filter it. My snippet inherits from PaginatorSnippet[T] and the list method uses a template to build a paged table. My problem is that I don't know how to store my query state. Here's what I've tried so far:
* A RequestVar - it's all fine until I click a page link generated by the PaginatorSnippet[T].paginate method. That does a GET request and my RequestVar disappears.
* I tried turning my snippet into a StatefulSnippet. Again, the same problem - clicking the pagination links doesn't POST (of course!) the stateful snippet hidden input and the search value disappears.
* A SessionVar - that seems to work. The only downside is that my state is there forever and when I navigate away from the site, and then come back, my search criteria stay the same as before. Ideally I'd like those to be reset.
It looks like I'm trying to build something pretty common, and I'm doing something wrong. Can somebody point me to the best way to store search criteria across requests? Maybe I have to plug into the way PaginatorSnippet generates paging links, but the *pageUrl* overridable method returns a string and I seem to need a closure that would get executed on the next request to, say, load a RequestVar with the proper object.
Thanks,
Hristo