Each General Interface application maintains a separate local data cache. If two applications are embedded on a single web page, each has its own cache. This local data cache should not be confused with the browser file cache for temporary Internet files. The General Interface local data cache is an in-memory, JavaScript hash of parsed XML documents that disappears when the browser window is closed. Any XML document, including XML, CDF, and XSL files, can be stored in the local data cache. Controls that display XML data interface with the local data cache by way of the jsx3.xml.Cacheable interface. This class provides methods that link a GUI object and the local data cache data it needs. The GUI object never refers to the data by reference. Only the local data cache references the XML document object, facilitating improved dereferencing and object cleanup. The Share Resources property is an important property of GUI classes that extend Cacheable (Menu, Tree, Matrix, and so on). When the Share Resources property is set to false (default setting) and the GUI object is removed from the General Interface DOM, the associated XML and XSL documents are also removed from the local data cache. Set this property to true if two GUI objects refer to the same document or if the document should remain in the local data cache after the GUI object is removed. Accessing the Correct CacheTo load files into the local data cache for use at runtime, call methods of the jsx3.app.Cache class. All cache method calls must be qualified with application namespace information. If the namespace for your application is app1, use the following syntax when storing and retrieving documents: app1.getCache().method_name You can cache any XML, CDF, or XSL document using the openDocument() method. The openDocument() method allows you to specify the URL of a file to load and parses the file into a jsx3.xml.Document instance. To cache the document, provide a second parameter to use as the cache ID as follows: app1.getCache().openDocument
("http://ibiblio.org/bosak/coriolan.xml","someCacheId");
To explicitly load a file into cache independently of the openDocument() method, use the setDocument() method. To retrieve a file from cache, use the getDocument() method as follows: app1.getCache().getDocument("myDocument");
Shared Global CacheIf you need to share a cache document with other applications running in the same page, use the shared global cache that is provided by the General Interface system as follows: var objSharedXML = jsx3.getSharedCache().getDocument("abc");
When a document is requested from the local data cache and the document isn't found, the General Interface system queries the shared global cache. For example, if the local data cache doesn't have a document named abc, each of the following calls is equivalent, assuming that the application namespace is app1: var objXML = jsx3.getSharedCache().getDocument("abc");
or var objXML = app1.getCache().getDocument("abc")';
Pre-caching XML DocumentsGeneral Interface controls that implement the jsx3.xml.Cacheable interface will automatically load their associated XML document into the local data cache when first painted. Otherwise, loading XML data into the local data cache is typically the domain of the developer. In General Interface Builder, project files can be configured to load automatically when the application loads. To manually specify which project files are automatically loaded into cache, right-click the file name in the Project Files palette and select Auto Load. Any type of project file except a GUI component and a mapping rule can be configured to automatically load. For more information on Auto Load options, see File Profile Dialog. When you're working in General Interface Builder, XML and XSL project files can be manually loaded or reloaded into the local data cache by doing the following:
To view the contents of the local data cache in General Interface Builder, choose Palettes > Local Data Cache. |
Contents
|
