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.

Sunday, March 18, 2007

Inheritance in Oracle ADF Business Components

If necessary, in Oracle ADF Business Components it is possible to use inheritance. Inheritance is especially useful when iterative approach for project implementation is used and requirements aren't stable. For example, let's say primary requirement was to display records for all employees. Later, analyst has asked to implement functionality of filtering employees by salary value. In this case, instead of creating completely new two additional View objects, you can extend existent View object. More information on this topic you can find in Oracle ADF Developer's Guide For Forms/4GL Developers - 25.9 Creating Extended Components Using Inheritance.

I have created sample application -, which shows how you can use inheritance with your business components. For the data source is used EMPLOYEES table from standard HR schema. The logic is the same as I have described it above - there is base View object and two extended. Business Components diagram for this sample:

EmployeesHighSalaryView retrieves records from database with salary value greater than entered, and EmployeesLowSalaryView with lower. Both of those View objects differs from their base View object by query Where clause.

How you can create extended View objects? There is nothing simpler - just use Oracle JDeveloper wizard. You should open Create View Object dialog and in the first step specify base View object you want to extend:

Other steps are the same as for usual View object.

In Presentation layer, View objects extended from base View object are used in similar way as usual View objects. In this sample I have added to the Data Model only extended View Objects, without base object. Data control looks like:

Sample application logic - user enters salary value and submits it by pressing Show button. When button is pressed, the same value is passed to both extended View objects. First View object shows employees with salary higher than entered and second View object with lower. This screen shows how it looks in practice:

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

Saturday, March 10, 2007

Trip to Finland capital - Helsinki

During this week I was in Helsinki, Finland. City have seen to me very practical, with well developed infrastructure for public sector. I mean, that it seems there is no problems with hotels, restaurants, transport and other services. It's not very cold in Helsinki now, only -4..0 °C, and almost no snow. In the city center they have trams, with advertisements - 'FEEL California, TASTE California', this looks quite interesting in cold Finland ;-)

Architectural style of the city center - broad roads, high buildings, big squares:

It is possible, that there is no terrible traffic jams in the city, because Helsinki have a subway. However, at 8:30 PM subway station hall was quite empty - only one person:

I have noticed, that in Helsinki, Russian culture presence is strong. It feels everywhere - architecture, street names and even souvenirs ;-). Russian souvenirs in Helsinki:

There is Russian culture presence in Helsinki, because Finland was a Grand Duchy of Russia (1809-1917). However, there was The Language Decree issued in 1863 by the Emperor of the Russian Empire Alexander II. It was the beginning of the process through which Finnish became an official administrative language equal to Swedish. In the Senate Square in Helsinki there is the monument to Alexander II "The Liberator":

The same monument, from closer look:

I hope, provided information will be useful, if you will be planning a trip to Helsinki.

Sunday, March 4, 2007

Many-to-Many mapping in Oracle TopLink

This kind of mapping in relational world is constructed using three tables. However, in object world only two classes are used for many-to-many. I have developed sample application -, that shows how many-to-many is supported in Oracle TopLink. For this sample I'm using Readers/Blogs mapping - one reader can read many blogs and one blog can be read by many readers.

SQL scripts for database schema are available in sample application lt.andrejusb.utils package under Model project.

Many-to-many mapping in Oracle TopLink is enabled by adding attribute with ValueHolderInterface type and corresponding accessors to the one of two classes involved into relationship. In developed sample I have added ValueHolderInterface type attribute - blogs, into Reader class. When accessors are created, it's time to enable many-to-many mapping using Oracle TopLink wizard in JDeveloper. To do this expand descriptor for Reader and double-click blogs element, this element is unmapped. When wizard dialog will be opened, set values for Reference Descriptor and Relation Table. Also, select - Private Owned and choose source and target references. General tab in mapping wizard should look like this:

If many-to-many will be successfully configured, JDeveloper will show appropriate icon for blogs attribue:

So, mapping is enabled, now we can test it. I have developed JUnit test suite, where insert and select is performed. Many-to-many test method code:

JUnit shows green light - there is no errors: