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 keys (or values), where the keys can be of any type.– это хранилище объектов. Так же как объект Map в JavaScript, это коллекция ключей (или значений), в которой ключи могут быть разных типов.

Используйте методы данного класса, например, в widget client scripts, чтобы управлять объектами. 

ПримерUse the methods of this class, for example, in the widget client scripts to operate the objects. See the code example below:

Code Block
languagejs
themeEclipse
titleStorage usage
linenumberstrue
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.


Используйте этот метод, чтобы получить значение на основе ключа.

Параметр:

НазваниеТипОбязательныйДефолтное значениеNameTypeMandatoryDefault Value
keyStringYДNН


ReturnВозврат:

TypeТипDescriptionОписание
StringThis method returns an item specified by a key.


ExampleПример:

Code Block
languagexml
titlegetItem
linenumberstrue
SimpleStorage.getItem('name'); // "Adam"

hasItem(key)

Use this method to check if there is a key in the storage.

Parameter:

NameTypeMandatoryDefault valuekeyAnyYN

Return:

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

Данный метод предназначен для проверки наличия ключа в хранилище. 

Параметр:

НазваниеТипОбязательныйДефолтное значение
keyлюбойДН


Возврат:

ТипОписание
BooleanМетод возвращает значение true, если ключ, указанный в параметре key был найден; в противном случае, метод возвращает false.


ПримерExample:

Code Block
languagexml
titlehasItem
linenumberstrue
SimpleStorage.hasItem('name'); //  true

setItem(key, value)

Use this method to set a value based on a key.

Parameters:


Используйте этот метод, чтобы установить значение, на основе ключа. 

Параметры:

Название

ТипОбязательныйДефолтное значение

Name

TypeMandatoryDefault Value
keyStringYДNН
valueAnyЛюбойYДNН


ReturnВозврат:

TypeТипDescriptionОписание
VoidThis method does not return a valueДанный метод не возвращает значение.


ExampleПример:

Code Block
languagexml
titlesetItem
linenumberstrue
SimpleStorage.setItem('name', 'Adam')


getEntries()

Use this method to get an array of pairs (value, key).

TypeDescriptionArrayThis method returns an array containing value pairs; otherwise, it returns an empty array.

Используйте этот метод, чтобы получить массив пар (значение, ключ).


Возврат:

ТипОписание
ArrayМетод возвращает массив пар значений или пустой массив.


ПримерExample:

Code Block
languagexml
titlegetEntries
linenumberstrue
SimpleStorage.getEntries(); //  [["name", "Adam"],[ ["secondName", "Smith"]]]

getKeys()

Use this method to get an array of keys.

Return:

TypeDescriptionArrayThis method returns an array containing values; otherwise, it returns an empty array.

Используйте этот метод, чтобы получить массив ключей. 

Возврат:

ТипОписание
ArrayМетод возвращает массив значений или пустой массив.


ПримерExample:

Code Block
languagexml
titlegetKeys
linenumberstrue
SimpleStorage.getKeys(); //  ["name", "secondName"]

getSize()

Use this method to get the amount of the values stored.


Используйте данный метод, чтобы узнать количество значений в хранилище. 

ПримерExample:

Code Block
languagexml
titlegetSize
linenumberstrue
SimpleStorage.getSize(); //  2

reset()

Use this method to empty the storage.

Return:

TypeDescriptionVoidThis method does not return a value.

Используйте этот метод, чтобы очистить хранилище. 

Возврат:

ТипОписание
VoidДанный метод не возвращает значение.

ПримерExample:

Code Block
languagejs
themeEclipse
titlereset
SimpleStorage.reset();


Table of Contents
classfixedPosition