Monday, December 24, 2012

Conditional Validation in ADF BC

ADF BC offered out of the box business validation support is quite advanced - allows to control validation execution conditionally. Still some functionality is missing - easy configuration for execution order. Now we have entity and attribute level validations, but really this doesn't give any guarantee that entity level validation will not be invoked when attribute value is changed (especially true for ADF table component). In the future ADF versions I would like to have more control over validation execution order and time. This post is to demonstrate what is available now - conditional validation execution. Validation rule can be executed conditionally in ADF BC, for example depending on user security role (based on use case requirement, we may want to skip certain validation for the super user).

Sample application - contains validation rule implemented for Salary attribute value check:

Conditional execution expression for the validation rule is based on Groovy and is accessing ADF security context to evaluate if super user role is granted to the current active user:

If current use is not a super user - validation rule will be invoked.

Don't forget to set AutoSubmit=true on the ADF UI for the field to be validated (this is typical ADF beginners mistake) - otherwise validation will not be displayed immediately after data change:

There are two users (both with welcome1 password) defined in the system, one of them is super user:

Test with super user - redsam1:

Change salary value to be 300, less than 500 - validation is passed for super user:

Test with regular user - redsam2:

Change salary value to be less than 500 - validation is executed for the same Eemployees EO:

No comments: