[Activities & Places] How to save and display the criterias again when hitting the back button ?

41 views
Skip to first unread message

Celinio

unread,
Sep 25, 2012, 10:59:36 AM9/25/12
to google-we...@googlegroups.com
Hi,
We are using Activities and Places.
I have a search view with several fields (criterias) and a submit button. When the user selects a few criterias and clicks
on the submit button, the activity runs the search method and displays the results in a new result view.
If the user goes back the search view is displayed again but the previous selected criterias are lost.
How can i save them ?
I know it has something to do with places and tokens and the history class but i have not found a clear example yet.
Can someone give me some explanation or point me to a link ?

Thanks for helping.

Chris Lercher

unread,
Sep 26, 2012, 7:55:52 AM9/26/12
to google-we...@googlegroups.com
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).

Chris Lercher

unread,
Sep 26, 2012, 7:59:21 AM9/26/12
to google-we...@googlegroups.com
On Wednesday, September 26, 2012 1:55:53 PM UTC+2, Chris Lercher wrote:
you can use HTML5 Storage (consider browser support).

Forgot to mention: You could also save them in a cookie. 
Reply all
Reply to author
Forward
0 new messages