Sunday, May 17, 2009

Parent Action Activity in ADF Task Flow

Recently I have faced a problem, when was trying to navigate to ADF Task Flow Call activity. The problem was, that I was initiating navigation from inside the region and navigation flow was defined not in bounded region ADF Task Flow, but inside parent bounded page ADF Task Flow. This means, navigation outcome from parent ADF Task Flow was simply invisible for button I have created inside region. But as usual in most of the cases, ADF provides very elegant solution to solve problem of external navigation from inside the region. I will describe it in this post.

The problem is, that I have bounded ADF Task Flow, however main page is using region and this region can't see declared navigations from this ADF Task Flow:

Region is used on main page, this region provides table of Countries, user can select any country and navigate to Location ADF Task Flow:

And here is the answer for described problem - in order to navigate from region using navigation rule from parent ADF Task Flow, you can use Parent Action activity inside region ADF Task Flow:

Only one thing you need to do is to define parent-outcome property, or in other words - navigation outcome from parent ADF Task Flow you want to use. In my case it is child navigation outcome:

Defined parent outcome will navigate to ADF Task Flow call activity and will open locations page.

On runtime, when user will press Location button implemented in region component, navigation from parent ADF Task Flow will be triggered:

Correct list of locations is returned:

You can download sample application for this post -

Useful hint, when user will return to Countries table, in order to show previously selected record, set DisplayRow = selected for af:table component:

Saturday, May 16, 2009

Inheritance Feature in Oracle ADF BC - Part 2

My today post is second post that describes inheritance functionality support in ADF BC. I will describe how you can use inheritance in View Objects. In previous post I was describing inheritance in Entity Objects - Inheritance Feature in Oracle ADF BC Part 1. Inheritance on View Object layer adds more object abstraction, you can operate not only different sets of data based on discriminator, but implement polymorphism for View Row classes. For more information, you can read 35.7.5 Working with Polymorphic Rows section from ADF Developer Guide.

I have developed sample application -, based on application from previous post - Updated sample contains additional View Objects, extended from Country. Those new View Objects are CountriesAfricaView and CountriesEuropeView:

In the View Row class of CountriesView, I have defined calculateProfit method. This method will be overridden in extended View Objects:

I will create only two overridden View Objects from possible four - for Africa and Europe discriminator values. CountriesAfricaView inherits calculateProfit method:

And CountriesEuropeView inherits same calculateProfit method:

I have defined Row Class for both extended View Objects, in those classes I'm overriding calculateProfit method from parent Row Class of CountryView:

For example, in CountriesEuropeViewRowImpl class I'm setting profit value to 500, while in CountriesAfricaViewRowImpl class to 200 and finally in CountriesViewRowImpl to 700. This means rows that belong to Asia and America discriminator value, will get 700 value for Profit attribute:

Last step, when enabling inheritance in View Objects layer, you need to set Subtypes in Application Module for polymorphic View Object - CountriesView in our case:

Press Subtypes button and and choose available View Object that extends parent:

In View layer, from Backing Bean, I'm scrolling through all rows from CountriesView and invoking calculateProfit method. Through implemented polymorphism, this method will be invoked for specific row based on its discriminator type, we dont need to specify it directly:

During runtime, I will invoke method from Backing Bean, by pressing Set Profit button:

To test that polymorphism really works, go to Europe section and check that Profit value is set to 500, as it was specified in overridden method:

Then go to Asia section, and check that Profit is set to 700, as it was specified in the Row Class of parent CountriesView:

Spanish Summary:

El post anterior, mostró como aplicar el concepto de Herencia en las Entidades. Sin embargo el mismo principio puede ser aplicacion a los componentes View Object. En este post, Andrejus nos muestrá, de manera práctica como aplicar herencia entre Vistas.