Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / data / proxy / SessionStorage.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * @author Ed Spencer
17  *
18  * Proxy which uses HTML5 session storage as its data storage/retrieval mechanism. If this proxy is used in a browser
19  * where session storage is not supported, the constructor will throw an error. A session storage proxy requires a
20  * unique ID which is used as a key in which all record data are stored in the session storage object.
21  *
22  * It's important to supply this unique ID as it cannot be reliably determined otherwise. If no id is provided but the
23  * attached store has a storeId, the storeId will be used. If neither option is presented the proxy will throw an error.
24  *
25  * Proxies are almost always used with a {@link Ext.data.Store store}:
26  *
27  *     new Ext.data.Store({
28  *         proxy: {
29  *             type: 'sessionstorage',
30  *             id  : 'myProxyKey'
31  *         }
32  *     });
33  *
34  * Alternatively you can instantiate the Proxy directly:
35  *
36  *     new Ext.data.proxy.SessionStorage({
37  *         id  : 'myOtherProxyKey'
38  *     });
39  *
40  * Note that session storage is different to local storage (see {@link Ext.data.proxy.LocalStorage}) - if a browser
41  * session is ended (e.g. by closing the browser) then all data in a SessionStorageProxy are lost. Browser restarts
42  * don't affect the {@link Ext.data.proxy.LocalStorage} - the data are preserved.
43  */
44 Ext.define('Ext.data.proxy.SessionStorage', {
45     extend: 'Ext.data.proxy.WebStorage',
46     alias: 'proxy.sessionstorage',
47     alternateClassName: 'Ext.data.SessionStorageProxy',
48     
49     //inherit docs
50     getStorageObject: function() {
51         return window.sessionStorage;
52     }
53 });
54