Interface jQuery.sap.storage.StorageModule: jquery.sap.storage


A Storage API for JavaScript.

Provides methods to store data on the client using Web Storage API support by the browser. The data received by this API must be already serialized, in string format. Similarly, the API returns the retrieved data in serialized string format, so it is the responsibility of the caller to de-serialize it, if applicable.

Attention: The Web Storage API stores the data on the client. Therefore do not use this API for confidential information.

One can get access to the 'default' storage by using jQuery.sap.storage directly or alternatively via factory functionality available as jQuery.sap.storage(jQuery.sap.storage.Type.session) returning an object implementing this interface.

A typical intended usage of this API is the storage of a string representing the state of a control. In such usage, the data is stored in the browser session, and the methods to be used are put and get. The method remove can be used to delete the previously saved state.

In sake of completeness, the method clear is available. However, it should be called only in very particular situations, when a global erasing of data is required. If only keys with certain prefix should be deleted the method removeAll should be used.


Since: 0.11.0.
Method Summary
clear()Deletes all the entries saved in the session (Independent of the current Storage instance!).
get(sId)Retrieves the state string stored in the session under the key sStorageKeyPrefix + sId.
getType()Returns the type of the storage.
isSupported()Returns whether the given storage is suppported.
put(sId, sStateToStore)Stores the passed state string in the session, under the key sStorageKeyPrefix + sId.
remove(sId)Deletes the state string stored in the session under the key sStorageKeyPrefix + sId.s

sStorageKeyPrefix is the id prefix defined for the storage instance (@see jQuery.sap#storage)

removeAll(sIdPrefix)Deletes all state strings stored in the session under the key prefix sStorageKeyPrefix + sIdPrefix.
Method Detail
clear(): boolean
Deletes all the entries saved in the session (Independent of the current Storage instance!).

CAUTION: This method should be called only in very particular situations, when a global erasing of data is required. Given that the method deletes the data saved under any ID, it should not be called when managing data for specific controls.

Returns:
{boolean} true if execution of removal was successful or the data to remove doesn't exist, and false if the feature is unavailable or a problem occurred
get(sId): string
Retrieves the state string stored in the session under the key sStorageKeyPrefix + sId.

sStorageKeyPrefix is the id prefix defined for the storage instance (@see jQuery.sap#storage)

Parameters:
{string}sId Id for the state to retrieve
Returns:
{string} the string from the storage, if the retrieval was successful, and null otherwise
getType(): jQuery.sap.storage.Type|string
Returns the type of the storage.
Returns:
{jQuery.sap.storage.Type|string} the type of the storage or "unknown"
isSupported(): boolean
Returns whether the given storage is suppported.
Returns:
{boolean} true if storage is supported, false otherwise (e.g. due to browser security settings)
put(sId, sStateToStore): boolean
Stores the passed state string in the session, under the key sStorageKeyPrefix + sId.

sStorageKeyPrefix is the id prefix defined for the storage instance (@see jQuery.sap#storage)

Parameters:
{string}sId Id for the state to store
{string}sStateToStore content to store
Returns:
{boolean} true if the data were successfully stored, false otherwise
remove(sId): boolean
Deletes the state string stored in the session under the key sStorageKeyPrefix + sId.s

sStorageKeyPrefix is the id prefix defined for the storage instance (@see jQuery.sap#storage)

Parameters:
{string}sId Id for the state to delete
Returns:
{boolean} true if the deletion was successful or the data doesn't exist under the specified key, and false if the feature is unavailable or a problem occurred
removeAll(sIdPrefix): boolean
Deletes all state strings stored in the session under the key prefix sStorageKeyPrefix + sIdPrefix.

sStorageKeyPrefix is the id prefix defined for the storage instance (@see jQuery.sap#storage)

Parameters:
{string}sIdPrefix Id prefix for the states to delete
Since:
1.13.0
Returns:
{boolean} true if the deletion was successful or the data doesn't exist under the specified key, and false if the feature is unavailable or a problem occurred