Showing posts with label ADF Business Components. Show all posts
Showing posts with label ADF Business Components. Show all posts

Monday, 2 December 2019

Creating first oracle ADF Application

In this post, I will show how to create an oracle ADF application and create Entity Object and ViewObject and test the Business Component.

We will create the following in the blog below.
  1. Create an oracle ADF Application.
  2. Create an Entity Object.
  3. Create a View Object.
  4. Create an Application Module.

Let's start.

1. Creating an ADF Application.

 

Open JDeveloper and create a new Application.


Then from the dialogue select Applications->ADF Fusion Web Application. JDeveloper IDE can be used to make many types of Applications. Oracle ADF Applications are made under this head.


Creating an Application involves 6 Steps.
In first you have to write Application Name and Application Package Name. In this case, I have used the name "EmployeeDetailsAPP". I have also given the package name as "employeedetailsapp"
.

ADF Application support MVC and an Application is divided into 3 parts
  • Model (Business Layer)
  • View (View layer)
  • Controller. (Control Flow)
An ADF application is divided into two Projects, one is Model and other is ViewController.
The windows below show the first project i.e. Model and its constituents.



The windows below show the second project i.e. ViewController and its constituents.



This is the last step, here leave the selection to default.


Now application structure is made. In the middle section you can see the steps for developing the application which is shown by default.


After that you have to create database connection which will be used in the Application.



As we have created the Database Connection, the next step is to create an Entity Object.


Select the database connection which will be used for creating the Entity Object.


Now we have to select the Database Table i.e. DEPARTMENTS for which Entity Object will be created.


Click on next. Now you can see the Attributes of the Table DEPARTMENTS


In this dialog you can see the attribute properties. All the properties are inherited from Database Table. e.g. you can see the Attribute "DepartmentId" is Primary key and a mandatory column. From here the properties can be changes as per the need, but it is advised not to change these.



In this window from will see the summary. Now click on Finish.


Here is DepartmentEO which we have created.


Here are the business rules of the table which are inherited by Entity Object.


As we have created the Entity Object, now we will create a View Object based on Entity Object. This is also called updateable ViewObject.



Here we have to specify the name of the ViewObject. In the Data Source selection select Entity.


In the Entity Object section select the Entity Object for which you want to create View Object.



Then in the next dialog you will have option to select the attributes of Entity Object which will be considered while creating ViewObject.


Select the select all icon to select all the attributes.


Here you can see the attributes properties.


In this dialog you can select order by clause for your ViewObject.


This is the summary.


Now as you can see we have created DepartmentsEO and DepartmentVO.


Now to run the ViewObject we need to create an Application Module. Application Module is the Transaction Controller of the ADF Application. All the database activity are performed by Application Module.


As the name of the Application is EmployeeDetailsApp, I have names Application Module as EmployeeDetailsAM. Its good practice to give name to Application name.



Now as we have created the ApplicationModule. Go to the Data Model Section and add a instance of ViewObject from the Left panel.


Now as we have created all the needed Business components we need to run and test the Application Module.


When you run the application a tester window will appear as you can see the image below. As you can see that the fields such as DepartmentName,DepartmentId,etc. are editable. As this ViewObject is based on EntityObject, this can be used for performing CRUD operations.


In this blog i have demonstrated till the Model Layer. In the Next blog i will show you how we can perform CRUD operation on a Web page.

Followup post coming soon.... ☺️


Next Post : https://adfjavacodes.blogspot.com/2020/01/crud-operation-on-webpage-in-adf.html

Saturday, 30 November 2019

What is an Entity Object in Oracle ADF?

EntityObject in ADF represents an individual Object in the data source. Such as database Tables. It contains all the properties of the database table.

Analogy: EntityObject in oracle ADF represents a table in the database which stores the data.


Entity Object contains all the properties of the database table, such as Database Constraints, Primary Keys, Foreign Keys, etc. and also table column properties such as Columns, Column Type, Column Precision Scale, Column Default Value, etc.

Entity Object is responsible for facilitating DML operation in database tables. Before it pushes the data in the database it validates with all the constrains of the database table and ensures that all the data it is sending in the data is correct. This helps in avoiding any corrupt data posting in the database. This helps in reducing database calls and adds to the real-time performance of the Application.  



Similarity between Database Objects and ADF Business Components

Oracle ADF is an Application development framework for Rapid Application Development. Oracle ADF uses Business components in the Model Layer to perform the transactions. ADF Business components are similar to Database Objects.

Suppose we have to create a database to store Department and Employee data in the database. For this, we will have to create two tables DEPARTMENTS and EMPLOYEES where DEPARTMENTS will be a master and EMPLOYEES will be detail table.

For the above scenario, we will have to do the following in the database.
  1. Create table DEPARTMENTS.
  2. Create table EMPLOYEES.
  3. Create a Foreign Key between DEPARTMENTS and EMPLOYEES to establish a master-detail relationship.
  4. SQL Query to perform DML operations i.e Create, Read, Update and Delete operations.

 If we have to create an ADF application for viewing and updating the above database structure then the following Business Objects will be created.
  1. Entity Object "DepartmentsEO" to represent the DEPARTMENTS Table.
  2. Entity Object "EmployeesEO" to represent the "EMPLOYEES" Table.
  3. Association "DeptToEmpAS" to represent the Foreign Key relationship.
  4. ViewObject "DepartmentsVO" and "EmployeeVO" to represent the SQL queries to represent DEPARTMENTS and EMPLOYEES tables respectively.

 In short, we can understand the similarity with the image below.