Last update: 7/4/2011
I just put some additions in blue.
Distributing some of its post's key points:
BC Validation Lifecycle
Levels of validations:
- Attribute
- Fires as soon as the attribute's value is changed and user moves out of that attribute.
- Entity
- Fires when the user moves from one record to another record.This is used for validations which are dependent on more than one attribute
- Eg: Say the commission for an employee should not exceed 10% of his salary.In this case commission can not be validated at attribute level,because user might enter commission first and then salary next.But it can be validated at entity level.i.e; when the user moves from one employee record to another employee record.(One can assume salary is mandatory)
- Transaction
- Fires when all attribute and entity level validations are completed.A transaction level validation is executed at the end.An example is a master-detail validation where a master needs to have only one child as favorite among all child rows.
Every validation can have a validation execution condition which skips executing the validation when the condition is not met.
Validation entry points in EOImpl:
When a attribute or entity validation is invoked the super class handles this process by calling the following methods:
- When an attribute is set setAttributeInternal(int) is called which invokes all the attribute level validations,this can be clearly seen because the first line in every set method will be setAttributeInternal which runs all the attribute validations and updates the entity attribute to the newValue.
- For entity level validations the method invoked is validateEntity() which runs all the entity level validations.
The main entry points are setAttributeInternal(int) and validateEntity based on validation level.
Apart
from these beforeCommit(TransactionEvent) afterCommit(TransactionEvent)
doDML(int) postChanges() are some of the important methods in ADF
life-cycle.
I will just add also the methods of Custom implementation (if any) of DBTransactionImpl2.
Finally do not forget to set -Djbo.txn.handleafterpostexc=true.
When all validations are successful postChanges is
invoked and all changes are posted to the database and finally commit is
issued.
What happens when a value is changed and a commit is invoked?
In simple terms:
The
application module->gets the DBTransaction and calls
commit->DBTransaction issues a validate call to all its entities in
its data model->Every vo/entity validates itself and finally the
transaction gets commited.
For master-detail entities the
master validate will invoke child validation and the chain is invoked
recursively till the last child vo.
No comments:
Post a Comment