Difference between revisions of "Functions.showMessage"
From AgileApps Support Wiki
imported>Aeric m (Text replace - 'showMessage(' to 'Functions.showMessage(') |
imported>Aeric m (moved ShowMessage to Functions.showMessage) |
||
(13 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:showMessage}} | {{DISPLAYTITLE:showMessage}} | ||
;Description: | ;Description: | ||
This function displays a message to the user, either at the top of page or in a dialog, depending on the context<noinclude>, using the [[Java API]]</noinclude>. | |||
:* | :* The basic version of the function displays a message string. | ||
:* With additional options, a localized version of a message can displayed. | |||
:{| border="1" cellpadding="5" cellspacing="0" | :;Considerations: | ||
::* The function displays the message in the UI, irrespective of any database insertions or updates (in other words, without interrupting the program flow). | |||
::* If the function is called multiple times, the messages are concatenated, and displayed together when the code returns to the platform. (Only one dialog is ever displayed.) | |||
::* The text is displayed in HTML format, so linebreaks (<tt><nowiki><br></nowiki></tt>) and text formatting (<tt><nowiki><b></nowiki></tt>, <tt><nowiki><i></nowiki></tt>) can be included. | |||
::* In a JSP page, this function does nothing. Use a JavaScript <tt>alert()</tt>, instead. | |||
;Syntax: | |||
:<syntaxhighlight lang="java" enclose="div"> | |||
void Functions.showMessage(String message); | |||
void Functions.showMessage(String key, String[] args); | |||
</syntaxhighlight> | |||
To display a localized message: | |||
::{| border="1" cellpadding="5" cellspacing="0" | |||
|- | |- | ||
!Element | !Element | ||
! | !Type | ||
!Description | !Description | ||
|- | |- | ||
|key|| | |key || String || {{:key}} | ||
|- | |- | ||
|args|| | |args || Array of String || Optional. Causes the first parameter to be treated as a key. | ||
*If no additional arguments are passed, the original key (the message string) is displayed. | |||
*If arguments are passed, the | *If arguments are passed, the key is used to retrieve a [[Custom Label]] in the current language, with the supplied arguments injected into it. | ||
*If | |||
|} | |} | ||
To provide a key for a label that has no arguments (for example, for a label in the <tt>#custom</tt> category), use: | |||
:<syntaxhighlight lang="java" enclose="div"> | |||
Functions.showMessage("#custom.label", null) | |||
</syntaxhighlight> | |||
To include linebreaks in the message, specify <nowiki><br></nowiki>: | |||
:<syntaxhighlight lang="java" enclose="div"> | |||
Functions.showMessage("Include <br> for <br> newline"); | |||
</syntaxhighlight> | |||
;Return: | ;Return: | ||
:*Returns the localized message configured on the key in the [[Translation Workbench]] | :*Returns the localized message configured on the key in the [[Translation Workbench]]. | ||
:*If no key is configured in the translation workbench, then the passed key is returned | :*If no key is configured in the translation workbench, then the passed key is returned. | ||
<noinclude> | |||
[[Category:Utility]] | |||
</noinclude> |
Latest revision as of 02:22, 12 November 2014
- Description
This function displays a message to the user, either at the top of page or in a dialog, depending on the context, using the Java API.
- The basic version of the function displays a message string.
- With additional options, a localized version of a message can displayed.
- Considerations
-
- The function displays the message in the UI, irrespective of any database insertions or updates (in other words, without interrupting the program flow).
- If the function is called multiple times, the messages are concatenated, and displayed together when the code returns to the platform. (Only one dialog is ever displayed.)
- The text is displayed in HTML format, so linebreaks (<br>) and text formatting (<b>, <i>) can be included.
- In a JSP page, this function does nothing. Use a JavaScript alert(), instead.
- Syntax
- <syntaxhighlight lang="java" enclose="div">
void Functions.showMessage(String message); void Functions.showMessage(String key, String[] args); </syntaxhighlight>
To display a localized message:
Element Type Description key String A category name, followed by '.' and a message or label identifier (a "token").
Example: #categoryname.tokennameargs Array of String Optional. Causes the first parameter to be treated as a key. - If no additional arguments are passed, the original key (the message string) is displayed.
- If arguments are passed, the key is used to retrieve a Custom Label in the current language, with the supplied arguments injected into it.
To provide a key for a label that has no arguments (for example, for a label in the #custom category), use:
- <syntaxhighlight lang="java" enclose="div">
Functions.showMessage("#custom.label", null) </syntaxhighlight>
To include linebreaks in the message, specify <br>:
- <syntaxhighlight lang="java" enclose="div">
Functions.showMessage("Include
for
newline");
</syntaxhighlight>
- Return
-
- Returns the localized message configured on the key in the Translation Workbench.
- If no key is configured in the translation workbench, then the passed key is returned.