JDeveloper 10.1.3 saw the introduction of "Validators," a declarative approach to defining business rules and error messages against Entity Objects (EOs) within ADF Business Components (
Documentation on this can be found within the Oracle Application Development Framework Developer’s Guide For Forms/4GL Developers under the section 6.7 Using Declarative Validation Rules.
The JDeveloper 11g Technical Preview (TP) edition introduces extended functionality which can be categorised under the tabs they exist within the Add Validation Rule dialog. This post specifically looks at the Rule Definition tab within the dialog. Refer to the above documentation on how to invoke the dialog.
The following validator types have been introduced in JDev 11g:
Collection Validator - this is a good addition but maybe poorly named validator - possibly Group By Validator or Aggregate Validator would be a better name. What it allows you to do is compute an aggregate value on an attribute in the current EO using an aggregate function such as Sum, Count, Average, Min or Max. The result can then be compared against a Literal, Query Result and so on like the Compare Validator.
How is this useful? Imagine a scenario where you have a business rule that says a training event shall only be stored in the database if there are 4 or more bookings. Creating a Collection Validator we can Count the number of bookings when the event is saved, and raise an appropriate error message if necessary if the bookings is less than 4.
Keys Exist Validator - in 10.1.3, it was possible for the user to change a FK child attribute (or in other words a detail attribute involved as an EO Accessor between two EOs) to an invalid value without the error being picked up until the data change hit the database and the FK constraint was violated. In 11g the declarative Keys Exist Validator allows us to check that the new attribute actually exists in another EO, or even VO, thus allowing us to validate FK values before they hit the database.
Expression Validator - provides validation of the EO against a Groovy expression. For more information read Steve Muench's post on Groovy Scripting Tips for ADF Business Components.
Within the existing validators the following changes and additional functionality have been added in JDev 11g:
In summary the 10.1.3 release introduced the basic declarative validators against Entity Objects in ADF Business Components. Within the 11g release this has given the JDeveloper team the opportunity to go beyond the obvious validation requirements and give sophisticated declarative business rule validation still with the advantage of minimal to no coding required.
Disclaimer: this post is written against the JDeveloper 11g Technical Preview (pre-production) edition. Oracle reserves the rights to remove or change this functionality in the final release so ensure to check your facts if you're using a later version when reading this post.
No comments:
Post a Comment