Thursday, November 10, 2011

Master Detail CRUD operations with Regions ADF 11g


This is an example that demonstrates how to create a Master Detail relationship between tables by using Regions. The main purpose of regions is the notion of reusability. With regions and bounded task flows we can reuse our pages into many other pages keeping the same functionality and having a more cleaner approach.

Download the Sample Application.

For this example we are going to use only one Model project and keep things simple.
We are going to create our Business Components through JDeveloper and it's wizards.
We are using Master Detail for Departments and Employees.

So, we are going to create two Bounded Task Flows that use fragments.
One for the Departments
One for the employees.

In each bounded task flow we drag and drop a view and place the appropriate names of departments and employees.

Then in the unbounded flow we create a jspx that will have two Regions defined.
One for the Department BTF
One for the Employees BTF

For Departments we are going to drag and drop the Departments iterator as a form with navigation buttons and submit button. Additionally, we add the createInsert and Delete Operation buttons next to submit

We do the same with employees. The only difference here is that  we drop an editable table and not a form. Additionally we drag it from the hierarchy and not the alone one in our Data Control. This means that we drag the detailed employees.

Next, we are going to create an index page in our unbounded task flow that will contain our Bounded Task Flows as regions.

In order to that, after we created the index page, we simply drag and drop each Bounded Task Flow as a Region

We do the same for the Employees Bounded Task Flow.
Up to now, we have our hierarchy done and well placed. Since we share the same application module instance, we are good to go!!
All that is left now is to place commit and rollback buttons in our Departments fragment and we are done!
For the rollback button we have to make a specific adjustment:
The emps region needs to be refreshed and indicate that the rollback is performed. For this reason we are going to set the refresh property as follows:

So, what we do here is, to set a refresh condition on our detail region. What we say here is, refresh emps fragment when the dept fragments is refreshed.

NOTE: this is a simple application demonstrating the ease of use of Regions. It is not intended to cover all aspects of regions.

Download the Sample Application.


No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...