Creating Business Logic Group in ADF

Tweet about this on TwitterShare on Facebook6Share on LinkedIn3Share on Google+0

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.
Click OK.

creating-business-logic-group-in-adf1

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.

creating-business-logic-group-in-adf2

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.

creating-business-logic-group-in-adf3

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.

creating-business-logic-group-in-adf4

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.

creating-business-logic-group-in-adf5

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.

creating-business-logic-group-in-adf6

In the Failure Handling tab, insert a message error and click OK.

creating-business-logic-group-in-adf7

Save everything.
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.

creating-business-logic-group-in-adf8

Other Employees show the attributes.

creating-business-logic-group-in-adf9

We will receive an error, if we try to change the value of DepartmentId attribute to Marketing (20).

creating-business-logic-group-in-adf10

This way you can continue personalizing your entities according the value of some attributes.

Tweet about this on TwitterShare on Facebook6Share on LinkedIn3Share on Google+0

Author: Waslley Souza

Consultor Oracle com foco em tecnologias Oracle Fusion Middleware e SOA. Certificado Oracle WebCenter Portal, Oracle ADF e Java.

Leave a Reply

Your email address will not be published. Required fields are marked *