On Tuesday, September 25, 2012 5:00:28 PM UTC+2, Celinio Fernandes wrote:
How can i save them ?
If you always only need the previously selected criteria, you don't have to store them in the token:
- Either save the values somewhere in your Java objects (wherever you want). When re-creating the search view, initialize it with the saved values.
- Or re-use the same view.
- Depending on your application, maybe also re-use the same presenter, but it's debatable if this is a good idea or not. If you don't re-use it, you might also have to initialize the presenter's state.
All of this however forgets the criteria, if the user leaves the GWT application, and returns to it via the back button. If you want to keep them across application restarts, you can use
HTML5 Storage (consider browser support).
I know it has something to do with places and tokens and the history class but i have not found a clear example yet.
This is only really necessary, if you want to allow users to go back through multiple sets of criteria in the history. But consider this:
The search view is presented before the user enters the criteria - therefore the current token can't contain the criteria. If you really want to have the criteria in the token, you would have to go to the search place again when hitting the submit button, adding the criteria to the search token, and then automatically go to the results place. (But this would happen only once after the submit button is pressed, not when returning via the back button.)
The easiest solution would be to combine the search criteria view and the results view into one (like Google search does).