Thursday, July 17, 2014

ADF Mobile 12c (MAF) Support for Master-Detail Data Control

ADF 12c is shipped with renamed mobile platform framework - Oracle Mobile Application Framework (MAF). Previously this was named ADF Mobile. 12c MAF is based on ADF Mobile and provides additional functionality and improvements. Everyone familiar with ADF Mobile 11g, should get up to speed with 12c without issues. I would like to highlight one interesting improvement implemented in 12c MAF - out of the box support for Master-Detail relationship. In previous 11g release, master record key was not preserved across different pages - developer was forced to store selected key in memory, to call execute method through invoke action in the second page and finally to reset a key. There was an alternative solution, described by Steven Davelaar - ADF Mobile – Preserving the Current Row Across Pages. Approach described in Steven's blog seems to be integrated into 12c MAF, there is no need to manage selected Master key manually, framework does this for you.

Sample application -, is based on HR schema loaded into local SQLite database and implements 2 level Details. Top Master is a Region:

First Detail screen brings a list of all Countries, from selected Region:

Second Detail screen displays available Locations, from selected Country:

Sample application provides navigation springboard, now there is only one Task Flow available - Address (may be there will be more options in the future):

Overall, 12c MAF is a great step forward - improved performance, better and cleaner UI, new features. MDS Seeded Customizations are supported now for mobile applications implemented with 12c MAF.

Sample comes with HR schema structure and data:

HR structure and data is loaded to the local SQLite database on initial application startup:

SQLite database is a physical file and we are opening JDBC connection. This is a database for single user, one user will be using it - no concurrency:

I will describe below, how to create Master-Detail structure and generate Data Control. There is a special extension available for similar task - A-Team Mobile Persistence Extension for Oracle MAF. However, for this exercise I would like to do it myself.

Firstly we should start with a model. There is Master-Detail relationship between Regions and Countries. Region object included a list of Country objects:

Country object in turn includes a list of Location objects, this is 2nd dependency:

This is our basic model, nothing complex. Model needs to be populated with data, this can be done with SQL, as all our data is stored locally in SQLite DB. Region, Country and Location rows are retrieved using SQL, Master-Detail relationship is populated manually:

Master-Detail relationship would not work, if there would be no Primary Key defined for Master object. By default, key is not set, when Data Control is generated. We need to edit Data Control object explicitly:

Here we can set a Primary Key for the attribute:

Task Flow displays relationship between Regions -> Countries -> Locations, there must be Primary Key set at least for Regions and Countries:

Important rule to know, 12c MAF doesn't really remembers current row in Data Control - it rather searching for iterator name and retrieves current state. This means, iterators in different pages must have the same names, otherwise current row key will not be resolved (even for the same data model object).

As for example, Region fragment:

Is based on data retrieved from regionsIterator:

This means Country fragment, displaying detail data:

Must have reference to Master iterator with the same name, as it is created in the first page Region (regionsIterator):


Anonymous said...

Hi, i would like to follow this blog. However, i can't download the zip file.

Andrej Baranovskij said...


Yes, Google quota for download is overused. Send me email, I will forward this sample app to you.


Anonymous said...

Hi Andrejus,

How we can implement the same master detail data in a single region itself in MAF amx page ?
Like MAF list view (with parent details and each list item holding the child data) of dynamic no.of rows.