Thursday, December 19, 2013

ADF Groovy basic notes

Some of the properties of groovy scripting language

- Groovy is a scripting language having java like syntax
- Groovy is executed at run time
 Can be used in Entity and View objects in attribute validators(Entity Objects),attribute default values( Entity and View),bind variable default values ( View) place holder for error messages (EO validation rules)
- Define script expression validator or Compare validator 
- Error message tokens can be defined for handling validation failures 
- Conditional execution of validatiors are possible 
- Default value of bind variable in view object can be defined using groovy expression 
- Default value of view criteria 
- Default value and optional re-calculation condition for EO
- Value of transient for EO and VO 


Referencing Buisiness components objects in Groovy expression
Top level object is "adf" . Accessible ADF objects throgh groovy are 
- adf.context - Reference to ADFContext 
- adf.object - Equivalent to this operator in java.
- Entity Objects attributes - Reference methods and attributes of EntityImpl class.
- Entity Objects script validator rules - Attributes and method of ViewImpl class.
- View Object attributes 
- Bind Variable in view Object 
- Bind variable in view accessors 
- Transient attributes 
- adf.error 
- adf.userSession 
- adf.currentDate 
- adf.currentDateTime 
- Referencing custom buisiness components methods and attributes 
eg. Sal*12 - annualsalary .
PromotionDate>HireDate 

Method of entity class in validation rule.For validators use source keyword
eg. source.getDefaultSalaryForGrade()

- newValue - Attribute value being set 
-oldValue - current value of attribute being set 

if(Job=’SALESMAN’)
{
 return newValue<source.getMaxSalaryForGrade(Job)
}

Manipulating business component attribute values in a groovy expression
RowSet Objects
-          rowSetAttr.sum(GroovyExpr)
-          rowSetAttr.count(GroovyExpr)
-          rowSetAttr.avg(GroovyExpr)
-          rowSetAttr.min(GroovyExpr)
-          rowSetAttr.max(GroovyExpr)
EmployeesInDept.sum(“Sal+adf.object.getBenefitsValue(Job)”)

1 comment: