From Ajax Patterns
Tags: Object Persistence
In A Blink
Object persistence has become an important part of many development projects because of the improved structure of coding that it provides. With object persistence, objects can be manipulated with normal programming techiques, and their state can be stored in persistent storage (on the server or client). In future sessions, the persisted objects can be restored to their previous state.
Standard object manipulation is a very natural programming technique. Persisting objects in other languages has already proven very powerful in improving code structure, for example in Java (JDO implemented through Hibernate, JPOX, etc), and simplifying the job of storing state information.
When to persist the object data?
Objects can be explicitly loaded and saved. Or you can use a class of persistable objects that manage get and set calls, and the data can be persisted when these calls are made.
Where to persist the data
Object data can be stored on the server through remote calls, or it can stored locally using a local storage technique such as Dojo.Storage.
Ajaxdo is a framework to save and load objects to a server connected to an SQL database.
Authenteo uses a language extension of # symbol (it does precompilation) to denote persisted fields (to allow for transient fields as well) on persistent objects. For example if you have an object that represents a list of webpage objects in a persistent object "listOfPages" we could this:
var webpage = listOfPages#; // get the third page in the list var pageName = webpage.#name; // get the name of the page var pageContents = webpage.#content; // the contents of the page
Now I could change the name of the webpage:
webpage.#name = "New webpage name"; // This change is immediately sent to the server, and is persisted
Dojo.Storage/Dojo Offline Toolkit provides the ability to store data local in persistent storage on a browser.