AgileApps Support Wiki Pre Release

Difference between revisions of "Functions.throwError"

From AgileApps Support Wiki
imported>Aeric
m (Text replace - 'throwError(' to 'Functions.throwError(')
 
imported>Aeric
 
(7 intermediate revisions by the same user not shown)
Line 22: Line 22:


;Syntax:
;Syntax:
:<syntaxhighlight lang="java" enclose="div">
void = Functions.throwError(String key [, String[] args])</pre>
</syntaxhighlight>


<pre>void = Functions.throwError(String key [, String[] args])</pre>
If no arguments are needed (for example, for a label in the <tt>#custom</tt> category), use:
 
:<syntaxhighlight lang="java" enclose="div">
If no arguments are needed, use:
Functions.throwError("#custom.label",null)
 
</syntaxhighlight>
Functions.throwError("#custom.label",null)


;Return:
;Return:
Line 50: Line 52:
</syntaxhighlight>
</syntaxhighlight>


 
To include linebreaks in the message, specify <nowiki><br></nowiki>:
To include new lines in the message, specify <nowiki><br></nowiki>:
:<syntaxhighlight lang="java" enclose="div">
 
Functions.throwError("Include <br> for <br> newline");
<pre>Functions.throwError(“Include <br> for <br> newline”);</pre>
</syntaxhighlight>
 
|}
|}
<noinclude>


<noinclude>[[Category:Utility]]</noinclude>
[[Category:Utility]]
</noinclude>

Latest revision as of 02:19, 12 November 2014

Functions.throwError(key [, String[] args])
Description
Element Display Type Description
key string

A category name, followed by '.' and a message or label identifier (a "token").
Example: #categoryname.tokenname

String [] args string Optional

Declares an array of Strings in Java (or Arguments)

  • If arguments are passed, the call expects a token
  • If no arguments are passed, the message alone is displayed
Syntax
<syntaxhighlight lang="java" enclose="div">

void = Functions.throwError(String key [, String[] args])

</syntaxhighlight>

If no arguments are needed (for example, for a label in the #custom category), use:

<syntaxhighlight lang="java" enclose="div">

Functions.throwError("#custom.label",null) </syntaxhighlight>

Return
  • Returns the message configured on the key in the Translation Workbench
  • If no key is configured in the translation workbench, then the passed key is returned


Example
This example checks a parameter passed to it to see if it is equal to "Acme". If it is, the code calls throwError to display an error message saying that the account cannot be "Acme".

<syntaxhighlight lang="java" enclose="div"> if(requestParams.get("name").equals("Acme")) {

   // message "Account cannot be Acme" will be shown to the user in the UI.
   Functions.throwError("Account cannot be Acme");

} else {

   // Normal business logic.

} </syntaxhighlight>

To include linebreaks in the message, specify <br>:

<syntaxhighlight lang="java" enclose="div">

Functions.throwError("Include
for
newline"); </syntaxhighlight>