Buslocalstore |
Helps in persisting information across sessions by writing it to a Local XML Store on a client machine.
Syntax
HTML |
<div cordysType="wxp.library.BusLocalStoreid=localStoreID > ... </div> |
The Microsoft's #default#userdata behavior can be used to store Web page information, styles, variables and state in Microsoft Internet Explorer 5 and above. This is more dynamic and has greater capacity than cookies. This is particularly useful for the Web pages that rely on user identification and information. Once the user information is saved, it can be reloaded even when the Microsoft Internet Explorer is closed and re-opened. The buslocalstore component acts as a thin API over the Microsoft's #default#userdata behavior.
The component provides a set of methods through which local user based data can be managed. The user information is stored in the Local XML Store in the form of XML documents, with the same name as the name of the file for which the data is stored. This Local XML Store has a maximum capacity of 1MB or 128 XML documents. Therefore, storage of XML documents should be done on a discretionary basis.
An expiry time can be fixed for each of the XML documents stored in the Local XML Store. Each time the browser is opened it checks the Local XML Store and deletes all the documents whose expiry date is over.
In Windows machines, the user data is stored in the following location: <User's home directory> > application Data > Microsoft > Internet Explorer > UserData
This library, apart from saving the user data XML file in the Local XML Store, also creates a file called Local_Store_Index, which contains the root nodes of all the "indexed" user data XML documents in the Local XML Store. This file is helpful in listing the available XML documents in Local XML Store from the Local XML Store Editor.
The Local XML Store also consists of an XML document called Userpreferences, which stores the name of the last-applied style sheet, and also other user preferences. This library provides the necessary methods for saving as well as retrieving this Userpreferences XML document.
To dynamically add and initialize this component, you can use the initializeHTMLElements or addType methods of the Application object.
The methods provided by the buslocalstore library to persist data on the client machine are as follows:
Table 1. List of Methods
Method |
Description |
---|---|
Creates a new XML document in the Local XML Store. |
|
readXml(name) |
Returns the XML document stored in the Local XML Store specified by the variable name. If not found, it returns NULL. The document returned can be an anonymous one or can have reference in Local_Store_Index. |
Saves the XML document in the Local XML Store. |
|
Deletes the XML document from the Local XML Store. |
|
getIndex |
Returns an XML document which contains only the root node of the indexed Local XML Store documents. If the Local_Store_Index file is not available in the Local Store, then this method creates the file.This method just reads the Local_Store_Index file and lists the indexed files, which may not match with the actual number of XML files available in the Local Store as it doesn't consider the un-indexed files available in the Local Store. |
getUserPreferences |
Returns an XML document containing the User preferences. If the Userpreferences file is not available in the Local Store, then this method creates a new Userpreferences file and returns it. |
saveUserPreferences(userpreferences) |
Saves the User preferences XML document. Returns true when saved. Unlike the other user data XML files in the Local XML Store, the Userpreferences file is saved forever without any expiration date. |
Note:
The Local XML Store has not been developed as a solution for off-line working with Web applications, but only for access of personalization data.