State Management

The Commerce Server Business Desk Framework maintains a client state dictionary that is used by modules to pass data between pages. Three client-side routines are provided for interacting with this dictionary. Use SetTemp (client-side) to store data, GetTemp (client-side) to retrieve data, and ClearTemp (client-side) to remove previously stored data. The data to be stored can be any variant type, including objects.

To keep this dictionary operating efficiently, care should be taken to clear values that no longer need to be stored in this dictionary.

All pages displayed within a particular instance of Business Desk share this dictionary, and there are no mechanisms to prevent one page from overwriting a value stored by another page. For this reason, you need to ensure that the dictionary key names that you use are unique and not used by another module. One common practice is to prefix all key names with the module name or some variation thereof.

One important use of the client state dictionary is when nested edit pages are being used. Often, the nested edit page needs to pass information back to the calling edit page. For example, this information might concern newly created objects or renamed objects. The nested edit page stores the relevant information in the client state dictionary, usually in the ONTASK routine associated with the Save task. The information can then be retrieved from the client state dictionary in the callback routine in the calling edit page.

Similarly, Business Desk also provides routines for storing state information on the server that can be accessed from client-side script. These routines convert a client-side Dictionary object into XML, use XMLHTTP to transfer it to the server, convert the XML back to a Dictionary object on the server, and then save it in the Session object. The reverse operation retrieves the saved state from client-side script. For more information about saving state on the server, see dSetServerState (client-side)dGetServerState (client-side), and dClearServerState (client-side).

Modules can use cookies to save small amounts of state across calls to different pages. Use this state management method only when storing less than 100 bytes of data per action page.


All rights reserved.