Upgrade to ExtJS 4.0.2 - Released 06/09/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  * @class Ext.data.proxy.SessionStorage
18  * @extends Ext.data.proxy.WebStorage
19  * 
20  * <p>Proxy which uses HTML5 session storage as its data storage/retrieval mechanism.
21  * If this proxy is used in a browser where session storage is not supported, the constructor will throw an error.
22  * A session storage proxy requires a unique ID which is used as a key in which all record data are stored in the
23  * session storage object.</p>
24  * 
25  * <p>It's important to supply this unique ID as it cannot be reliably determined otherwise. If no id is provided
26  * but the attached store has a storeId, the storeId will be used. If neither option is presented the proxy will
27  * throw an error.</p>
28  * 
29  * <p>Proxies are almost always used with a {@link Ext.data.Store store}:<p>
30  * 
31 <pre><code>
32 new Ext.data.Store({
33     proxy: {
34         type: 'sessionstorage',
35         id  : 'myProxyKey'
36     }
37 });
38 </code></pre>
39  * 
40  * <p>Alternatively you can instantiate the Proxy directly:</p>
41  * 
42 <pre><code>
43 new Ext.data.proxy.SessionStorage({
44     id  : 'myOtherProxyKey'
45 });
46  </code></pre>
47  * 
48  * <p>Note that session storage is different to local storage (see {@link Ext.data.proxy.LocalStorage}) - if a browser
49  * session is ended (e.g. by closing the browser) then all data in a SessionStorageProxy are lost. Browser restarts
50  * don't affect the {@link Ext.data.proxy.LocalStorage} - the data are preserved.</p>
51  */
52 Ext.define('Ext.data.proxy.SessionStorage', {
53     extend: 'Ext.data.proxy.WebStorage',
54     alias: 'proxy.sessionstorage',
55     alternateClassName: 'Ext.data.SessionStorageProxy',
56     
57     //inherit docs
58     getStorageObject: function() {
59         return window.sessionStorage;
60     }
61 });
62