When you have an entity, but in some cases, according the value of some attribute, you need to change control hints, default values or validation logic, you can create a Business Logic Group to help you. Using the Oracle Application Development Framework Documentation (4.8 Defining Business Logic Groups), let’s create a Business Logic Group for Employees entity.
In the sample application (ADFBusinessLogicGroupApp.zip) we will create a Business Logic Group that contain a Business Logic Unit. This Business Logic Unit will perform its business logic, if the value of JobId attribute is AD_PRE.
This article was published on OTN LA in brazilian portuguese, and you can read it here: Oracle ADF 12c: Criando Business Logic Group.
In the Applications window, double-click the Employees entity to create a Business Logic Group.
On the General page, go to Business Logic Groups section and click the Add icon.
Select JobId as Group Discriminator Attribute and set JobIdGroup as Group Name.
We have created the group, now we can add Business Logic Units to it.
In the Applications window, right-click the Employees entity and choose New Entity Business Logic Unit.
In the Create Business Logic Unit dialog, set AD_PRES as Unit Name and click OK.
This Business Logic Unit will identify the set of business logic for Employees with JobId attribute setted as AD_PRES.
Now we can redefine business logic.
In the Employees_JobIdGroup_AD_PRES file, click the General navigation tab.
Select the Salary, CommissionPct and ManagerId attributes, and click the Override button.
After we make attributes overridden, we can edit them.
We are limited to making modifications to only control hints, validators, and default values.
Select the Salary attribute and click the UI Hints tab.
Change the Display option to Hide.
This way, Salary attribute won’t be showed for this Group.
Repeat previous steps for CommissionPct and ManagerId attributes.
Click the Business Rules tab. Right-click the Entity Validators and choose New Validator.
Change Type to List, Attribute to DepartmentId, and add 10 and 90 to List of Values.
In the Failure Handling tab, insert a message error and click OK.
Right-click the Application Module and choose Run.
In the Oracle ADF Model Tester, we can test our business logics.
Employees with JobId attribute setted as AD_PRES don’t show Salary, CommissionPct and ManagerId attributes.
Other Employees show the attributes.
We will receive an error, if we try to change the value of DepartmentId attribute to Marketing (20).
This way you can continue personalizing your entities according the value of some attributes.