Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / SessionStorage.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-data-proxy-SessionStorage'>/**
19 </span> * @author Ed Spencer
20  * @class Ext.data.proxy.SessionStorage
21  * @extends Ext.data.proxy.WebStorage
22  * 
23  * &lt;p&gt;Proxy which uses HTML5 session storage as its data storage/retrieval mechanism.
24  * If this proxy is used in a browser where session storage is not supported, the constructor will throw an error.
25  * A session storage proxy requires a unique ID which is used as a key in which all record data are stored in the
26  * session storage object.&lt;/p&gt;
27  * 
28  * &lt;p&gt;It's important to supply this unique ID as it cannot be reliably determined otherwise. If no id is provided
29  * but the attached store has a storeId, the storeId will be used. If neither option is presented the proxy will
30  * throw an error.&lt;/p&gt;
31  * 
32  * &lt;p&gt;Proxies are almost always used with a {@link Ext.data.Store store}:&lt;p&gt;
33  * 
34 &lt;pre&gt;&lt;code&gt;
35 new Ext.data.Store({
36     proxy: {
37         type: 'sessionstorage',
38         id  : 'myProxyKey'
39     }
40 });
41 &lt;/code&gt;&lt;/pre&gt;
42  * 
43  * &lt;p&gt;Alternatively you can instantiate the Proxy directly:&lt;/p&gt;
44  * 
45 &lt;pre&gt;&lt;code&gt;
46 new Ext.data.proxy.SessionStorage({
47     id  : 'myOtherProxyKey'
48 });
49  &lt;/code&gt;&lt;/pre&gt;
50  * 
51  * &lt;p&gt;Note that session storage is different to local storage (see {@link Ext.data.proxy.LocalStorage}) - if a browser
52  * session is ended (e.g. by closing the browser) then all data in a SessionStorageProxy are lost. Browser restarts
53  * don't affect the {@link Ext.data.proxy.LocalStorage} - the data are preserved.&lt;/p&gt;
54  */
55 Ext.define('Ext.data.proxy.SessionStorage', {
56     extend: 'Ext.data.proxy.WebStorage',
57     alias: 'proxy.sessionstorage',
58     alternateClassName: 'Ext.data.SessionStorageProxy',
59     
60     //inherit docs
61     getStorageObject: function() {
62         return window.sessionStorage;
63     }
64 });
65 </pre>
66 </body>
67 </html>