The Oracle ADF (Application Development Framework) is an application framework that builds on Java Platform, Enterprise Edition (Java EE) standards and open-source technologies. Because of its declarative nature, Oracle ADF simplifies and accelerates development by allowing developers to focus on the logic of application creation rather than coding details.
Let’s start programming in Oracle ADF and creating a master-detail Task Flow of departments and employees. Download sample application: MasterDetailApp.zip
To create a new Oracle ADF Application, navigate to File | General | Applications, select Fusion Web Application (ADF), and click on OK.
Change the following properties:
- Application Name: MasterDetailApp
- Application Package Prefix: br.com.waslleysouza
We don’t need to change the projects, so click on Finish.
Now, we have an application with two projects, Model that is responsible by model layer and ViewController that is responsible by view and controller layers.
To create Business Components, right-click on Model project and select New.
Navigate to Business Tier | ADF Business Components, select Business Components from Tables, and click on OK.
If this is the first time you create an application, you will have to create a database connection.
Click on plus icon to create the connection.
After configure the properties, click on OK twice.
An Entity Object represents a row in a database table and simplifies modifying its data.
We will only need the Employees and Departments tables for this application.
Click on Query to search tables from HR Schema and select Employees and Departments. Click on Next.
A View Object represents a SQL query and simplifies working with its results.
Select Employees and Departments, and click on Next.
We don’t need Read-Only View Object. Click on Next.
Application Module is the transactional component that UI clients use to work with application data.
Click on Finish.
Now, we have twelve files in our project:
- AppModule is an Application Module.
- Employees and Departments are Entity Objects.
- EmployeesView and DepartmentsView are View Objects.
- EmpManagerFkAssoc, DepMgrFkAssoc and EmpDepFkAssoc are Entity Associations. Entity Associations are business components that define a relationship between two Entity Objects.
- EmpManagerFkLink, DepMgrFkLink and EmpDepFkLink are View Links. View links are business components that define a relationship between two View Objects.
- Model.jpx file contains configuration information that JDeveloper uses in the design time to allow you to create the data model project with ADF Business Components.
To create Task Flow, right-click on ViewController project and select New.
Navigate to Web Tier | JSF, select ADF Task Flow, and click on OK.
Uncheck the Create with Page Fragments option, and click on OK.
Drag-and-drop a view component from Component Palette inside Task Flow.
Rename it to DepartmentEmployees.
Double-click on DepartmentEmployees, and click on OK to create the page.
Go to Component Palette and drag-and-drop Panel Splitter from Layout section inside page.
Change the Orientation property to vertical.
Go to Data Controls from Application Navigator pane, and expand AppModuleDataControl.
Drag-and-drop DepartmentsView1 inside first facet, and select Table | ADF Read-only Table.
Select Single Row option, and click on OK.
Go to Data Controls from Application Navigator pane, and expand DepartmentsView1.
Drag-and-drop EmployeesView3 inside second facet, and select Table | ADF Read-only Table.
Click on OK.
We need to refresh the second table when we select a row in the first table, to get the employees from department.
Select the second table, and go to Property Inspector pane.
Edit the PartialTriggers property, select the first table, and click on OK.
To run the application, right-click on task-flow-definition.xml and select Run.
Ps.: Instead of create two tables inside the page, you can drag-and-drop EmployeesView3 inside page and select Master-Detail | ADF Master Table, Detail Table.
This way you have the same result. =D