Sunday, March 25, 2007

Reusability in Oracle ADF Business Components

In Oracle ADF it is possible to create libraries for common solutions, and to reuse them later in several projects. This gives more productivity, project developer doesn't need to start from nothing - he will have working solutions at hand. If you would like to do this, there are instructions available in Oracle ADF Developer's Guide For Forms/4GL Developers - 25.7 Working with Libraries of Reusable Business Components.

There is nothing special when creating reusable library. In fact, you will need just to create specific deployment profile - Business Components Archive. This profile is used to create two JAR files - *CSMT.jar and *CSCommon.jar, which should be included into other projects. When reusing created library, developer will need to import those JAR files - instructions are available in Oracle ADF Developer's Guide (see above). After that, when library will be successfully imported, it will be possible to use provided components in Oracle ADF Business Components wizards.

Developed sample application is divided into two parts - and In first part reusable library is implemented, it comes under lt.andrejusb.model.reusable package - Entity and View object for COUNTRIES table from standard HR schema are created. Implemented reusable library contains deployment profile. Second part implements support for REGIONS table and reuse developed library.

Sample application page flow logic:

Locally implemented Regions functionality:

Show countries button invokes imported functionality. Countries for selected region are displayed in the table:

Functionality in View layer is implemented in common way, it doesn't depend on reusability we have used. For 'Show countries' af:commandButton is created af:setActionListener, that stores selected #{row.RegionId} value into #{processScope.regionId}. Data for table contained in countries.jspx page comes from imported component, this table depends on selected #{row.RegionId}. Dependency is implemented using ExecuteWithParams action and setRegionId invoke action.

ExecuteWithParams definition in countries.jspx page definition file:

setRegionId invoke action definition:

So, reusability in Oracle ADF Business Components can be achieved really easy - this may help to develop your projects more effectively.

When running sample application, don't forget to add adf-faces-impl.jar and jsf-impl.jar to application's WEB-INF\lib directory.


Muhammed Soyer said...

Hi Andrejus,
What is the difference between "Business Components Archive" and "ADF library JAR file"?
As I understand "ADF Library" is new to 11g and "BC Archive" is an older concept.


Andrej Baranovskij said...

Hi Muhammed,

You are right. "ADF Library" is new in 11g and substitutes "BC Archive". With ADF Library you can pack not only ADF BC, but for example ADF Task Flows as well.

I will write updated post for ADF BC reusability with ADF Libraries.


Mary Brownlie said...

Hi Andrejus:

I had been working on creating our reusable business component .jar in 11g. The documentation found here: Section 37.7 still states to use a Business Components Archive. Luckily I found this blog, as well as the following post on the forum (, or I would have started from the wrong approach.

Could someone please update Section 37.7 in the Oracle documentation so others don't have the same problem?