Groovy Debugging

Posted by Vijay Allen Raj on Oracle Blogs See other posts from Oracle Blogs or by Vijay Allen Raj
Published on Wed, 30 Nov 2011 00:34:54 -0600 Indexed on 2011/11/30 10:15 UTC
Read the original article Hit count: 342

Filed under:

Groovy Debugging - An Overview:

ADF BC developers may express snippets of business logic (like the following) as embedded groovy expressions:

  • default / calculated attribute values
  • validation rules / conditions
  • error message tokens
  • LOV input values (VO)

This approach has the advantages that:

  1. Groovy has a compact, EL-like syntax for expressing simple logic
  2. ADF has extended this syntax to provide useful built-ins
  3. embedded Groovy expressions are customizable
Groovy debugging support helps improve maintainability of business logic expressed in Groovy.

Following is an example how groovy debugging works.

Example:

This example shows how a script expression validator can be created and the groovy script debugged. It shows Step over, breakpoint functionalities as well as syntax coloring.

Let us create a ADFBC application based on Emp and Dept tables, and add a script expression validator based on the script:
 
if (Sal >= 5000){
//If EmpSal is greater than a property value set on the custom
//properties on the root AM
//raise a custom exception else raise a custom warning
if (Sal >= source.DBTransaction.rootApplicationModule.propertiesMap.salHigh)
{
adf.error.raise(
"ExcGreaterThanApplicationLimit");
}
else
{
adf.error.warn("WarnGreaterThan5000");
}
}
else if (EmpSal <= 1000)
{
adf.error.raise(
"ExcTooLow");
}
return true;

In the Emp.xml Flat editor, place breakpoints at various locations as shown below:

groovy4.JPG























Right click the appmodule and click Debug. Enter a value greater than 5000 and click next. You can see the debugging work as shown below:

groovy3.JPG





 





















The code can be also be stepped over and debugged.

© Oracle Blogs or respective owner

Related posts about /Oracle/ADF