Beta Draft: 2016-09-09

30.6 apex.lang namespace

30.6.1 apex.lang.addMessages

Add messages for use by getMessage and the format functions. Can be called multiple times. Additional messages are merged. It is generally not necessary to call this function, because it is automatically called with all the application text messages that have Used in JavaScript set to Yes.

Parameters


Table 30-19 Parameters for apex.lang.addMessages

Name Type Optional/Required Description

pMessages

Object

Required

An object whose properties are message keys and the values are localized message text.


Example

This example adds a message.

apex.lang.addMessages({
  APPLY_BUTTON_LABEL: "Apply"
});

30.6.2 apex.lang.clearMessages

Remove all messages.

Parameters

None.

Example

This example removes all messages.

apex.lang.clearMessages()

30.6.3 apex.lang.format

Same as formatMessage except the message pattern is given directly (already localized or isn't supposed to be). It is not a key. See "apex.lang.formatMessage".

Parameters


Table 30-20 Parameters for apex.lang.format

Name Type Optional/Required Description

pPattern

String

Required

The message pattern that contains one or more parameters %0 to %9.

...*

any

Optional

Optional replacement values one for each message parameter %0 to %9. Non string arguments are converted to strings.


Returns


Table 30-21 Returns for apex.lang.format

Type Description

String

The localized and formatted message text.


Example

This example returns Total cost: $34.00 assuming the totalCost variable equals 34.00.

apex.lang.format("Total cost: $%0", orderTotal);

30.6.4 apex.lang.formatMessage

Format a message. Parameters in the message %0 to %9 are replaced with the corresponding function argument. Use %% to include a single %. The replacement arguments are HTML escaped.

Parameters


Table 30-22 Parameters for apex.lang.formatMessage

Name Type Optional/Required Description

pKey

String

Required

The key is used to lookup the localized message text as if with getMessage.

...*

any

Optional

Optional replacement values one for each message parameter %0 to %9.


Returns


Table 30-23 Returns for apex.lang.formatMessage

Type Description

{String}

The localized and formatted message text. If the key is not found then the key is returned.


Example

This example returns "Process 60% complete" when the PROCESS_STATUS message text is "Process %0%% complete" and the progress variable value is 60.

apex.lang.formatMessage("PROCESS_STATUS", progress);

30.6.5 apex.lang.formatMessageNoEscape

Same as formatMessage except the replacement arguments are not HTML escaped. They must be known to be safe or are used in a context that is safe. See "apex.lang.formatMessage".

Parameters


Table 30-24 Parameters for apex.lang.formatMessageNoEscape

Name Type Optional/Required Description

pKey

String

Required

The key is used to lookup the localized message text as if with getMessage.

...*

any

Optional

Optional replacement values one for each message parameter %0 to %9.


Returns


Table 30-25 Returns for apex.lang.formatMessageNoEscape

Type Description

{String}

The localized and formatted message text. If the key is not found then the key is returned.


Example

This example returns "You entered <ok>" when the CONFIRM message text is "You entered %0" and the inputValue variable value is "<ok>". Note this string must be used in a context where HTML escaping is done to avoid XSS vulnerabilities.

apex.lang.formatMessageNoEscape("CONFIRM", inputValue);

30.6.6 apex.lang.formatNoEscape

Same as format, except the replacement arguments are not HTML escaped. They must be known to be safe or are used in a context that is safe. See "apex.lang.format".

Parameters


Table 30-26 Parameters for apex.lang.formatNoEscape

Name Type Optional/Required Description

pPattern

String

Required

The message pattern that contains one or more parameters %0 to %9.

...*

any

Optional

Optional replacement values one for each message parameter %0 to %9.


Returns


Table 30-27 Returns for apex.lang.formatNoEscape

Type Description

String

The localized and formatted message text. If the key is not found then the key is returned.


Example

This example returns "You entered <ok>" when the inputValue variable value is "<ok>". Note this string must be used in a context where HTML escaping is done to avoid XSS vulnerabilities.

apex.lang.formatNoEscape("You entered %0", inputValue);

30.6.7 apex.lang.getMessage

Return the message associated with the given key. The key is looked up in the messages added with addMessages.

Parameters


Table 30-28 Parameters for apex.lang.getMessage

Name Type Optional/Required Description

pKey

String

Required

The message key.


Returns


Table 30-29 Returns for apex.lang.getMessage

Type Description

String

The localized message text. If the key is not found then the key is returned.


Example

This example returns "OK" when the localized text for key OK_BTN_LABEL is "OK".

apex.lang.getMessage("OK_BTN_LABEL");