Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / data / proxy / SessionStorage.js
1 /**
2  * @author Ed Spencer
3  * @class Ext.data.proxy.SessionStorage
4  * @extends Ext.data.proxy.WebStorage
5  * 
6  * <p>Proxy which uses HTML5 session storage as its data storage/retrieval mechanism.
7  * If this proxy is used in a browser where session storage is not supported, the constructor will throw an error.
8  * A session storage proxy requires a unique ID which is used as a key in which all record data are stored in the
9  * session storage object.</p>
10  * 
11  * <p>It's important to supply this unique ID as it cannot be reliably determined otherwise. If no id is provided
12  * but the attached store has a storeId, the storeId will be used. If neither option is presented the proxy will
13  * throw an error.</p>
14  * 
15  * <p>Proxies are almost always used with a {@link Ext.data.Store store}:<p>
16  * 
17 <pre><code>
18 new Ext.data.Store({
19     proxy: {
20         type: 'sessionstorage',
21         id  : 'myProxyKey'
22     }
23 });
24 </code></pre>
25  * 
26  * <p>Alternatively you can instantiate the Proxy directly:</p>
27  * 
28 <pre><code>
29 new Ext.data.proxy.SessionStorage({
30     id  : 'myOtherProxyKey'
31 });
32  </code></pre>
33  * 
34  * <p>Note that session storage is different to local storage (see {@link Ext.data.proxy.LocalStorage}) - if a browser
35  * session is ended (e.g. by closing the browser) then all data in a SessionStorageProxy are lost. Browser restarts
36  * don't affect the {@link Ext.data.proxy.LocalStorage} - the data are preserved.</p>
37  */
38 Ext.define('Ext.data.proxy.SessionStorage', {
39     extend: 'Ext.data.proxy.WebStorage',
40     alias: 'proxy.sessionstorage',
41     alternateClassName: 'Ext.data.SessionStorageProxy',
42     
43     //inherit docs
44     getStorageObject: function() {
45         return window.sessionStorage;
46     }
47 });