First page Back Continue Last page Text

oracle adf workshop


Using a Script Expression Validator

A Script Expression validator enables you to use a Groovy expression that returns either true or false for validation, or to use an entire Groovy script. When you define a Script Expression validator, an <ExpressionValidationBean> tag is added to the XML file.

The following are some usage notes on the Script Expression validator:

All Java methods, language constructs, and Groovy constructs are available in the script.

Do not use { } to surround the entire script.

Use newValue to refer to the new value of the attribute being validated.

Use the return keyword just like in Java to return true or false, unless it’s a one-line expression, in which case the return is assumed to be the result of the expression itself. For example: Sal > 0.

You must either return true or false, or call adf.error.raise or adf.error.warn to display a message that is defined in your message bundle.

You can use built-in aggregate functions on RowSet objects by referencing the functions: sum(String attrName) — for example: sum(”Salary”), count(String attrName), avg(String attrName)

Use the ternary operator to implement functionality that is similar to SQL’s NVL() function. For example: Sal + (Comm != null ? Comm : 0).