Sunday, April 28, 2013

Master-Detail ADF BC Web Service for ADF Mobile

It seems like a bit unclear for the developers if ADF BC Master-Detail relationship can be reused out of the box through ADF BC Web Service in ADF Mobile. Short answer - yes, it can. In order to prove this I have developed sample application - second level Master-Detail relationship is exposed through ADF BC Web Service and consumed from ADF Mobile screens.

Mobile device in the first screen renders list of departments, second screen brings all employees from selected department and finally third screen brings subordinate employees (managed by). Here is ADF Mobile Task Flow implementation:

Here you can download sample application, it contains both parts - server side and mobile client.

First screen brings all departments:

Second screen displays list of employees for selected department, first Master-Detail:

Third screen displays list of subordinates, employees managed by selected employee, second Master-Detail:

ADF BC server side is implemented to support classical ADF BC Master-Detail relationship defined with View Links and registered in Application Module:

ADF BC Web Service is exposed with Master VO instance - DepartmentsView1. This instance is enabled with View Criteria (just to bring entire list of departments), empty parameter values for the View Criteria are accepted:

Something very important now. Based on documentation - 11.2.6 How to Support Nested Processing in Service-Enabled Master-Detail View Objects, you must set SERVICE_PROCESS_CHILDREN property on View Link for the Master-Detail relationship be enabled for ADF BC Web Service. I did this for Department-Employees View Link:

As well as for Employee-Subordinates View Link:

This is about the server side, now we switch to ADF Mobile client. You should know that ADF Mobile client Web Service Data Control is stateless (different from regular ADF BC Data Control), this means current row selection is not preserved when moving from one ADF Mobile page to another. For the Master-Detail relationship to work on ADF Mobile client, we must transfer current Master record key between pages, in Page Flow Scope as for example:

We can drag and drop Master-Detail relationship from Data Control as usual in ADF. Here how we can set correct Master key for Detail relationship:

Data Control method - setCurrentRowWithKey is invoked in the second page (detail for Employees based on Department). We are using old good method from ADF 10g times - invokeAction, in order to call executable method on page load:

The same for the third page, where second level detail is implemented for subordinates. Here we call two methods for setCurrentRowWithKey, one for Departments and second for current manager Employee:

Keep in mind that by default setCurrentRowWithKey will not work, because ADF Mobile Web Service Data Control doesn't inherit key setup from ADF BC. You need to set key attribute for each of Data Control bindings manually, from DataControls.dcx go and edit required binding:

JDeveloper generates definition XML file for the binding, you can set proper key. Even it still displays old key and there is no way to remove it, on runtime only proper key is used:

Key is set manually for Employees binding as well:

No comments: