You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

SimpleStorage is an object storage. Just like the Map object in JavaScript, it's a collection of key/value, and keys can be of any type.

Methods of this class can be used. for example, in widget client scripts to operate with objects. See the code example below for more clarity.

Storage usage
if (SimpleStorage.hasItem('portalLogo')) {
  s_widget.setFieldValue("HasLogo", true);
  s_widget.setFieldValue("logo", SimpleStorage.getItem("portalLogo"));
} else {
  await s_widget.serverUpdate();
  SimpleStorage.setItem('portalLogo', s_widget.getFieldValue("logo"));
}


getItem(key)


Gets a value based on a key.

NameTypeMandatoryDefault Value
keyStringYN


Return:

TypeDescription
StringThis method returns an item specified by a key.


Example:

getItem
SimpleStorage.getItem('name'); // "Adam"

hasItem(key)


Checks if there's a key in the storage.

Parameter:

NameTypeMandatoryDefault value
keyAnyYN


Return:

TypeDescription
BooleanThis method returns 'true' if the key specified in the key parameter was found; otherwise, it returns 'false'.


Example:

hasItem
SimpleStorage.hasItem('name'); //  true

setItem(key, value)


Sets the value based on a key.

Parameters:

Name

TypeMandatoryDefault Value
keyStringYN
valueAnyYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

setItem
SimpleStorage.setItem('name', 'Adam')


getEntries()


Gets an array of pairs (value, key).

TypeDescription
ArrayThis method returns array containing value pairs; otherwise, returns an empty array.

Example:

getEntries
SimpleStorage.getEntries(); //  [["name", "Adam"],[ ["secondName", "Smith"]]]

getKeys()


Gets an array of keys.

Return:

TypeDescription
ArrayThis method returns array containing values; otherwise, returns an empty array.

Example:

getKeys
SimpleStorage.getKeys(); //  ["name", "secondName"]

getSize()


Gets the amount of values stored.

Example:

getSize
SimpleStorage.getSize(); //  2

reset()


Empties the storage.

Return:

TypeDescription
VoidThis method does not return a value.

Example:

reset
SimpleStorage.reset();

  • No labels