Tuesday, November 3, 2009

Business Logic Groups in Oracle ADF 11g

I was reviewing Business Logic Groups functionality in Oracle ADF BC and was getting problems - correct Business Logic Unit wasn't invoked when needed. Its because I misunderstood documentation, and was trying to configure discriminator property for attribute. Its seems everything much more simple, you just need to specify discriminator value in Business Logic Unit name. Thanks to Steve Muench for this pointer. Actually, there is a tip in documentation as well, which I skipped while reading - 4.8.2 How to Create a Business Logic Unit.

Download sample application with working Business Logic Group defined for Employees EO - BusinessGroups.zip.

In order to define Business Logic Group, you need to specify which attribute from EO will be used as discriminator to choose between available Business Logic Units:


Next step is to define Business Logic Unit. Its very important at this step to enter correct Unit Name. It should reflect discriminator value for this Business Logic Unit. In my case it is IT_PROG, for employees working as programmers. It is a place where you need to specify discriminator:


In sample application I have created two Business Logic Units, one for IT_PROG and another for ST_CLERK JobId's:


In Business Logic Unit, you need to override attributes you want to change. Then you can change those attributes properties, add validation rules. In this example I have created validation rule for overridden Salary attribute:


Another validation rule for Salary attribute is defined in ST_CLERK Business Logic Unit:


I have specified different Salary attribute labels for IT_PROG and ST_CLERK Business Logic Units:


Additionally through Business Logic Unit you can implement custom behavior in Business Logic Unit Java class:


On runtime you can see Business Logic Group related behavior for IT_PROG:


And for ST_CLERK:

3 comments:

Karim H Abdellatif said...

Hello Andrejus,
Great topic, and very nice good feature, but when i create a new business logic group I can't choose DepartmentId to be discrimintor attribute and it forced me to choose firstName,LastName,Email,JobId and PhoneNumber only(HR schema)

Thank you
Karim Hasan

Andrejus Baranovskis said...

Hi Karim,

Yes, it seems it works only on String type attributes.

Regards,
Andrejus

Andrejus Baranovskis said...

I think its actually logical to have on String type for discriminator.

Andrejus