Background documentationClient Data Bag Locate this document in the navigation structure

 

The client data bag is a state management mechanism that enables you to share data between the iViews on the client side. All session data is stored and retrieved as key-value pairs using synchronous API methods.

The data bag lifespan is a single user browser session, so it is automatically cleared at the end of the session.

In a typical scenario a portal component stores client data to the data bag so that another component on the same page or on another page within the same browser session can retrieve and use this data.

Accessing Data in the Data Bag

The following code illustrates how to access data in the data bag:

  • Storing

    Syntax Syntax

    1. var selectedPerson = "JohnDoe"
      EPCM.storeClientData ("urn:com.sap.portal:testApp", "personSelected", selectedPerson);
      
    End of the code.
  • Retrieving

    Syntax Syntax

    1. var person = EPCM.loadClientData("urn:com.sap.portal:testApp", "personSelected");
      if (person != null){   /* process person */ }
      
    End of the code.
Data Storage Options: EPCF Level

The EPCF Level property defines whether EPCF functionality is available to an iView, as well as the way data is stored in the client data bag. This property is specified as a runtime configuration setting of the iView and affects the size of the resources sent to the client.

EPCF Levels

EPCF Level

Meaning

0

The EPCF is disabled

1

The EPCF is enabled, client data is stored in the browser cookies (default)

2

The EPCF is enabled, client data is stored in the Java applet that implements the data bag (for legacy purposes only)

The default level 1 enables full EPCF functionality and is suitable for most cases.

Since the data bag size in the browser cookies is limited to about 4 KB, we recommend to store in it only minimal amount of data, such as IDs or GUIDs. Delete the data once it is no longer needed, using the EPCM.deleteClientData method.

Level 2 is used to support legacy applications that need to store huge amounts of data. Otherwise it is not recommended because of the performance penalty caused by the loading of the Java applet.

Limitations: Data Types

The values stored in the data bag must be of the string type. Complex types, such as objects or object references, are not supported. These restrictions are necessary to guarantee the data bag functionality across all platforms that use the browser cookie-based implementation.

More Information

For the complete API reference, see Client Data Bag API.