Thursday, May 13, 2010

JDeveloper 11g PS2: ADF Region Reuse Inside ADF Region

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):

6 comments:

Hasim said...

Good Stuff.

Anonymous said...

Dear Andrejus

can u help me to solve this case

i want to add_bonus(100) to all employees whose salary = 1000

in other way i need set of steps to update field in table for specific rows but i want to do it using button action in jspx

Unknown said...

Hi Andrejus, I have a question whne i enter department id and click on serach button the table is rendered .On back end how do i pass the vale of department id to render the page . I mean my datacontrol to render the table needs input department id and when i drag and drop the table on page how do we define that the input will be taken from the department input text field.

Vinitha said...

Hi,

Good blog, I have a jsff inside for which i can get all components inside that jsff , even if there is a region in that jsff , i can the component ids inside that region in jsff , but my scenario is i have a jsff - > inside that i have a region -> inside that i have a region and i need to get the access of the components inside the second region, is it possible, kindly help me in the same.

Johnny said...

Hi Andrejus,

I run your sample application in JDeveloper 11.1.2.3.0. And I got message: " The region component with id: r1 has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance. It is recommended that you restructure the page fragment to have a single root component."

Is it safe?

Thanks.

Andrej Baranovskij said...

Hi Johny,

You can surround root components with single parent for example panel group layout component - warning message will disappear.

Andrejus