Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
SimpleStorage is an object storage. Just like the Map object in JavaScript, it is a collection of pairs key/valuecollects the key-value pairs, where the keys can be of any type.
Use the methods of this class, for example, to manage the data that can be useful for client-side scripts of the widgets or forms in the future. See the code example below:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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)
Use this method to get a value based on the key.
Name | Type | Mandatory | Default Value |
---|---|---|---|
key | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns an item specified by a a value of the specified key. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SimpleStorage.getItem('name'); // "Adam" |
hasItem(key)
Use this method to check if there is a key in the storage.
Parameter:
Name | Type | Mandatory | Default value |
---|---|---|---|
key | Any | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if the key specified in the key parameter was found; otherwise, it returns false. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SimpleStorage.hasItem('name'); // true |
setItem(key, value)
Use this method to set a value based on a key.
Parameters:
Name | Type | Mandatory | Default Value |
---|---|---|---|
key | String | Y | N |
value | Any | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SimpleStorage.setItem('name', 'Adam') |
getEntries()
Use this method to get an array of pairs (key-value, key).
Type | Description |
---|---|
Array | This method returns an array of arrays containing the keys names and their values; or it returns an empty array. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SimpleStorage.getEntries(); // [["name", "Adam"],[ ["secondName", "Smith"]]] |
getKeys()
Use this method to get an array of keys.
Return:
Type | Description |
---|---|
Array | This method returns an array containing that contains values, or an empty array. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SimpleStorage.getKeys(); // ["name", "secondName"] |
getSize()
Use this method to get the amount of the values stored.
Return:
Type | Description |
---|---|
Integer | This method returns the quantity of values in the storage. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SimpleStorage.getSize(); // 2 |
reset()
Use this method to empty the storage.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SimpleStorage.reset(); |
Table of Contents | ||
---|---|---|
|