Objective :
In this article we will discuss basics of Application Development Framework and how to use JDeveloper to develop business components .
What is Application Development Framework ( ADF):
Built on top of the MVC-based JavaServer Faces framework, Oracle Application Development Framework (ADF) forms the foundation for WebCenter Portal's components and services. ADF is an innovative, yet mature Java EE development framework available from Oracle, and, unlike most other frameworks, is directly supported and enabled by the award winning development environment, Oracle JDeveloper 11g.ADF provides unified access to back-end technologies like databases, web services, XML, CSV, BPEL, and many more. Furthermore, ADF provides data binding to connect UI with back-end data controls.Out of the box, ADF provides more than 100 data aware, JSF view components. The fine-grained JAAS security model gives developers and administrators full control over all aspects of application security
It is reference implementation of Java Server Faces(JSF) . In the year 2005/2006 Sun Microsystems has come with specifications known as JSF. They had specification / reference and implementation both . Earlier there were limited UI components available on other framework . The design goal was to put every UI components available in swing application such as mouse event , and other event sources etc into JSF that is available on web .Now they are available as a part of JSF implementation . JSF is a specification and ADF is reference implementation of this specification . Oracle implemented ADF ,Apache implemented it and named it as MyFaces , JBoss implemented it and named it as RichFaces .Not only 100 percent implementation of specification is done they have also added much more features which are not part of specifications such as business components , task flows , Data Visualization Tool (for pictorial representation of data ) .ADF is the framework which is used by all Fusion Middleware products which can be OIM , OAM , Webcentre . All FMW products are developed using JDeveloper . You need basic knowledge of ADF is required to for customization / to modify the existing task flows or pages .
Business Components in ADF:
Business logic and data access logic are available in Business Components. In essence there are three types of Business Components available .
1) Entity Objects( EO):
Some of the frameworks are available to communicate with database . Being a java programmer everyone one wants to view even the database in the form of java object . .For that there are so many frameworks introduced and they are called as Object Relational Mapping(ORM) framework. Here the tables are converted into java classes and each row will be converted into an object and that represents one row of that table. For example let’s say we have table called Student and has the following columns .
Column Name |
Data Type |
RollNo |
int |
Name |
varchar(30) |
Address |
Varchar(30) |
What this ORM framework does is it creates a class with the same mapping to the table . For example it generates the following class Student based on table having the variables mapping to the columns of the Student table and has getter/setter methods corresponding to the variables .
class Student
{
int rollno;
String name;
String address;
Student(int r, String n, String ad) // Constructor which will be called when the object is created
{
rollno=r;
name=n;
address=ad
}
public void setRollno(int roll)
{
rollno=roll;
}
public int rollno()
{
return rollno;
}
public void setName(String na)
{
name=na;
}
public int name()
{
return name;
}
public void setAddress(String addr)
{
address=addr;
}
public String getAddress()
{
return address;
}
}
Now we will create an object of the class Student.
Student s = new Student(21,”John”,”New York”);
Once you create the object, constructor will be called and the values passed to the constructor will be saved into the variables of the class . Also one new record will be inserted in the table Student . Now this we call it as entity object since it represents one entity of the table. We can modify the values by calling setter method .
s.setRollNo(45); So the rollno 23 which was inserted will be replaced by 45 i,e the corresponding row gets updated . So if you create a new object you will find a new row , if you delete the object that record gets deleted from the table . So if there are 100 records in the table you will find that 100 objects in the memory .Entity object represents each row in the table and corresponding class can be called as an entity class . Having getter/setter methods or mutators method is mandatory , apart from this custom methods can be added to define your custom logic . Suppose if you have a product table containing two columns quantity and price , and a line total is to be displayed on a page , which is not a column in the table . To display the total you can define one transient attribute as line total evaluate it to quantity * price . And we are marking it as transient so that it will not be persisted to the table but you can display it on the screen .Likewise you can define your own logic in the entity classes
2)View Objects( VO):
View Objects are created by keeping the web page in mind . So, for example on a web page I want to display all the students . There can be 100 students that are to displayed , so all 100 entity objects are encapsulated in VO and the data required to be displayed on the page will be available in this VO . For example entity object may have name , rollno , address , class , blood group , class etc , probably all these values are not required to displayed on page , so you can add all the 100 entity objects to the VO and you can remove the attributes which you are not displaying on the page . Ultimately the data required to be displayed on UI page is available with VO .It may also have some associated entity objects For example we may have two different objects employee and department entity objects . If you want to display the employee and its department , then on a VO we can add employee entity object and department entity object associate them with an association and display it on a page . VO can have one or more entity objects of different types which are associated .
3)Application Modules (AM):
It manages the transaction. It provides all the required transaction services . Application Modules are created by keeping user task in mind . To complete one end user task what all you need is added to to the application module. Application Module encapsulates all the VO’s which are required to complete one end user task/ use case . For example to transfer money from my account ,I will open Internet Banking Application . In the first page I will select my account , in the second page I will select the beneficiary , in third page I will enter OTP / some credit/debit card details and on the fourth page I will transfer it . So this is what I have completed one user task(use case) . All these 4 pages will be having 4 VO’s in the background , and all 4 VO’s will be added to the application module so that it manages the transaction for all those VO’s.If anything goes wrong in third page everything gets rolled back .It also used to expose the the business services to the world . For example consider HDFC bank’s loan department .There are so many financial firms that provide the loan on behalf of HDFC bank . So those should be able to submit the loan applications to the HDFC bank and retrieve the rate of interest and all those details . For that bank has to make its business services available to their business partner’s applications .
Using JDeveloper :
JDeveloper is the tool / IDE / editor meant for developing ADF Application .
Simple ADF application demonstration:
-
1)We will start the integrated Weblogic Server or OIM server can also be used as well .
2) Create a New Application by clicking on New Application .
3)Name the application for example as CerebraApp and select Fusion Web Application(ADF) as Application Template and click on Next.
4) By default Project name will be Model we will change it to BusinessServices and click on Next .
5) Leave the default package name as model and click on Next .
6) Change the default ViewController project name to UIProject and click on Next .
7) Keep the default Package name as view and click on Finsh.
8) Two projects will be created BusinessServices & UIProject within CerebraApp one for Busines services and one for UI . Also there will be checklists
Check List:
-
Plan your application and check it to Done once complete
You can click on Developer Guide and download the ADF guide .
b. Connect to a Database . If your application uses database you will have to create a Database Connection .
Currently we will not perform this step since we don’t want database connection .Similarly each of the task can be performed and mark it as done . It helps the developer how to start with . We will directly start with the project currently and ignore the check list .
9) Now in BusinessServices project I will add my business components .
-> Right click BusinessServices project and click on New.
-> Select ADF Business Components under Business Tier from Categories and Business Components from Tables and click on Ok
-> It will ask for connection , we will add one database connection .
Once you Test Connection it should be successful .If not you need enter correct database details .