Madhura
Madhura

Reputation: 589

How to retain page data(State) in gwt except using cookies

I have an application with 6-7 tabs. All I want is that whenever I close my browser and open it again, the page data should be retained i.e. the state of the page should be maintained. Now in my page I have thousands of values like several trees and textboxes and checkboxes etc.So storing all these values one by one in cookies is not a good idea.

I googled a lot but I didn't find any way to do this. Can anyone help me to find out a solution for this?

Upvotes: 0

Views: 176

Answers (2)

Andrei Volgin
Andrei Volgin

Reputation: 41089

I doubt that you have thousands of unique values on a page - it would mean a very bad design.

More likely, you have a tree, which shows the same values every time a user accesses this page (i.e. a list of items of certain kind), and various input elements that correspond to a particular data object (e.g. a product). In this case, the entire state of this page can be summarized as something like this:

myWebSite/?#OrderForm:user=123&category=5&product=xyz&size=large

When a user reloads this page (or comes back to it later), you app can parse this URL token, and it would know exactly what to show to the user: show OrderForm with all of its panels, checkboxes, etc., load and populate a tree with categories and products, set category 5 as selected in a menu, set product xyz as a selected item in a products tree, show details of this product in the details panel, and select size large in a ListBox of sizes.

This is, of course, just an example, but with the proper app design any "page" within the app can be described with just a few parameters and a very few (often one) data object. Then you can store this state in a URL token, in a cookie, in a server session, or persist in your database - you have many choices depending on your requirements.

Upvotes: 1

appbootup
appbootup

Reputation: 9537

There is no magic solution.

You might explore along the lines of -

Server Side approach - Activities and Places with Asyc calls to get the last stored values.

Client Side approach - Activities and Places with HTML5 local storage. 

Neither will be easy to use with the sort of caching feature you wish to see.

Upvotes: 1

Related Questions