In an application, there can be different information that should be saved and restored when required, e.g., when the application is closed and then opened. For instance, the current navigation history should be saved when closing the application so that the last displayed view is displayed again when reopening the application. Thus, the navigation manager implements special methods that characterize it as a state source. As there can be several state sources in an application, the application should have a state manager that "knows" about all of them and calls their methods to save/restore their states.
The StateManager object has a collection of state sources that should be notified when a request to save/restore the current state arrives. By default, only the navigation manager is added to this collection. To add another state source to this collection, use the state manager's addStateSource(stateSource) method. You can remove a state source from this collection when required by using the removeStateSource(stateSource) method.
When the HtmlApplication requests to save/clear/restore the application state, the StateManager object calls the saveState()/restoreState()/clearState() method, in which the corresponding method of each of the "known" state sources is called.
A storage to which the state manager saves the application state.
Adds an object that implements an interface of a state source to the state manager's collection of state sources.
Removes the application state that has been saved by the saveState() method to the state storage.
Removes a specified state source from the state manager's collection of state sources.
Restores the application state that has been saved by the saveState() method to the state storage.
Saves the current application state.