Edit Validate
form
|
Enter the body of a Java boolean function here. The value
your Java code is to validate is in an automatically declared
variable named theValue
.
Design the function to return true when the value is valid, and otherwise return false.
Your validation code can check character limitations, format limitations, or value range limitations. However, do not implement cross-edits — comparisons of one input field against another — in edit validate rules that are to be used in client-side validation, as the other inputs may not be available at the time the edit validate rule executes.
See More about Function rules and Examples — Using inline Java and PublicAPI facilities for additional guidance on Java code you can use here.
Field |
Description |
Java Source | |
Java |
Enter your Java source directly into the text area, Alternatively, click the pencil icon () to open your workstation's Java editor or Notepad. Include a Java Enter your Java using the editor, then exit from the editor to return the resulting source code into the form. See open authoring for instructions on setting up a Java editor.
Use the
You can use the normal Process Commander syntax to call a function rule: ruleset_library.FunctionName(arg1, arg2, arg3) where the RuleSet and library name are in lowercase bu the function name is in exact case. For example: double d_result = pegarules_math.Sqrt("4") In releases before Version 4.2SP6, a different fully qualified syntax was employed to call function rules. It still executes correctly, but is deprecated. |
To associate text from a message rule with the property, use the addMessage() PublicAPI method, as in following Java statement:
theProperty.addMessage("RuleMessageKey/tText1/tText2...");
where RuleMessageKey is a key to a Rule-Message rule, and the optional Text1, Text2 and so on are text values — separated by a backslash and literal t character — that supply values for the numbered parameters {1}, {2},... in the message rule text. (This method has no effect if the message identified by RuleMessageKey is already present.)
Use the pre-declared variable
myStepPage
and the ClipboardPage
interface in the Process Commander PublicAPI to access
properties on the primary page.
The standard function callWhen() is useful to evaluate a when condition rule within the Java code. For example:
return com.pegarules.generated.pega_rules_utilities.callWhen(tools, "IsGoodCustomer", tools.getPrimaryPage());