When I work with more complex Use Cases, it happens to face requirement, when it would be very efficient to reuse ADF regions inside another ADF regions. Same as we are using ADF region inside JSF page, to use it from another ADF region. This is quite common requirement especially for such systems, where ADF region based UI Shell is implemented. In such systems, all main screens are represented by ADF regions, sometimes we need to use smaller ADF regions inside.
Of course, it was possible to include ADF region inside another ADF region in previous JDeveloper 11g PS1 release as well. But, this approach was not working, with enabled ADF Security. On runtime, security was not propagated to nested ADF regions, and as result these regions were not rendered. Situation is changed now - in JDeveloper 11g PS2, security is propagated for nested ADF regions correctly.
In order to demonstrate benefits of nested ADF regions, I have updated sample application from my previous post - Dynamic Iterator Binding to Reuse View Link Relationship for Master-Detail. Download updated sample - DynamicIterator2.zip. In my previous post I was describing how you can implement dynamic iterators in Oracle ADF. Today I will use the same concept, to show how you can benefit from dynamic iterator binding together with ADF regions reuse.
I have extracted Departments fragment into separate ADF task flow - dep-flow. I will use this task flow as individual region and additionally will include it into Locations fragment (as nested region):
Inside locdep-flow, task flow dep-flow is called with two parameters. First parameter is passing value for dynamic iterator binding and second indicates that dep-flow will be refreshed in case of nested region:
Departments fragment contains Query component, I will render this component conditionally. If fragment will be opened on its own, Query will be rendered. In case of nested region, it is not rendered:
For conditional Query rendering, I'm using task flow input parameter and evaluating it in Expression Language:
Just to remind you, as dynamic iterator binding was described in previous post, here as well I'm using dynamic iterator binding inside Departments fragment Page Definition. You can see, when input parameter is NULL, top level View Object will be mapped to iterator. Otherwise, when I will pass parameter - detail View Object instance will be used:
Now lets focus on Locations fragment. I have created nested region for Departments inside Locations, same as I would create it on JSF page:
Through Locations fragment Page Definition file, I set values for Departments task flow input parameters - View Object instance name and currently selected Location Id. I need to provide current Location Id, because I want to trigger nested region refresh:
Now is the main part, nested regions security was not working in JDeveloper 11g PS1, I need to test it now. I have enabled ADF Security for test application, you can user predefined user scott/welcome:
We login into application:
Router activity from locdep-flow navigates us directly to Departments dep-flow task flow region (because departments parameter was set, refer to previous post). Query component is present:
If we press Locations button, user is navigated to Locations region present in locdep-flow (see task flow diagram). We have in Locations region - nested Departments region. Nested region brings detail data for master records from Locations table. For nested region I'm using same Departments fragment, as in dep-flow:
If I click on any Location Id item, it will navigate to Departments region from dep-flow, where it will render detail View Object instance for Departments (because we pass parameter from Locations):