Sunday, March 4, 2012

How to create ADF Application Module

ADF Application Module 

Step 1:

Right Click on AdfDemoModel  . New Gallery window will open up . Choose as in the below screen shot.

Step 2:
Enter Package : model.applicationmodule , Name : AppModule and click Next .

Step 3:

Expand model.view tree under Available View Objects and shuttle the EmployeesVO to the Data Model area .  A New instance of the EmployeesVO is created . we can create N number of instance of employeesVO when required.Click Next

NOTE : AM can also be created by the time we create VO . (Refer how-to-create-adf-view-objects.html Step10) If you did that so then AM will be created and  automatically an instance of that VO will be added to the AM Data model section. That is direct approach . we can do it in either of the way . Click Next

(Once you  shuttle the VO instance to the right side, it will be displayed in the Data Control Panel . Look at the Data Control section /  first screen shot in this post ADF Data Control )

Step 4 :

Just click Next .

Step 5 :

Optionally you can generate Java classes to add custom behaviour .

Step 6 :

Final look of AM with an instance of VO in it .

We have successfully created AM. Now how does it help ?? Here is the way , you can run an Application Module .  is not it looks good when we see data being retrieved  from DB Table and displayed when we  run AM ??

Right click on the AppModule  under model.applicationmodule and choose run .

Oracle Business Component Browser will open up and do as like in the screen shot .

Thats it !!!!!!!!!!

How to create ADF View Objects

What is View Object ?
A Typical View Object that lets you to work with set of rows .  View object contains SQL Query that collects data from Database . It can be associated with underlying entity object. At the same time VO query can be formed from various entity objects.

Step 1 :

Right click on AdfDemoModel project and select New (NOTE:If you have not created ADF Model project How to Create ADF Sample Application this will tell you how to get ready before creating View objects.View objects we create is based on entity objects which we created already.If you have not create entity objects yet, this will tell you how-to-create-entity-object ).

Step 2 :

Select the options as in the below screen shot

Step 3 ;

Enter Package : model.view , Name : EmployeesVO (since we are going to create employee VO out of employee EO ) . Select Updatable access through entity objects radio button. we will do CRUD operations later using this VO from UI ( Insert,Update operation). There are setting that you can set the way VO works (For ex : read only VO , this just helps to read data from DB not to do any CRUD operations) . Click Next

Step 4 :

Select the EmployeesEO from Avaiable area and shuttle it to Selected area and click Next .

Step 5 :

Shuttle all the attributes from left to right.

Step 6 :

Attribute settings can be made and there are various options .
Just click Next

Step 7 :

Using this step we can edit query .  Query can be edited from selecting Expert from SQL Mode drop down.
we can add where clause and order by to the existing query .Click Ok

Step 8 :

Bind variable can be added to the VO and it can be appended to the query at run time . Just Click Next

Step 9:

Java files can be generated for the VO which contains the getter and setter methods for the VO attributes.

Step 10 :

Check the application module check box and type as given in the below screen shot and click Next and click Finish. NOTE : If you uncheck this option when creating VO then we need to externally create AM and add VO instance to it . Refer how-to-create-adf-application-module and add VO to it . If you check application module when creating VO, then you can skip the lesson how-to-create-adf-application-module and add VO to it .

Step 11 :

Final look of just created VO

NOTE :  we can also create VO when creating Entity Object ( adf-model-how-to-create-entity-object Step 10) . This is direct approach .

How to create ADF Entity Objects

Entity objects are classes that encapsulate the business model , data and its relationship . Suppose for example, we have a table Person in DB and we create one Person entity that maps to the Person table in DB . Each Entity object instance represent a row in table.

Now we will see how to create ADF Entity objects in our ADF Model Project in step by step process ( If you have not created ADF Model project How to Create ADF Sample Application this will tell you how to get ready before creating entity objects)

Step 1:

Right click on AdfDemoModel Project, select New

Step 2:

Choose the options as per the Screen shot and click  ok.

Step 3:

In the Initialize Business Component Project you will get to see the Database Connection parameters which is connected with the Database which we configured earlier.If not created from the earlier post den you can create the same using this link  How to Create ADF Sample Application (Refer Step 8). You can also create the Database connection on the spot by clicking on the plus sign near connection drop  ok.

Step 4 :

Create Entity object - step 1 of 6 dialog window will open up and click Browse as shown in the picture

Step 5 :

Type the respective database table name in the object name text box (say Empl)  and click query. you will see the EMPLOYEES table in available objects area .  you can also select the object types if required .click ok.

Step 6 :

Enter the package name and Name as it is in the screen shot .  Suffix EO for all the entity object name to understand  easily as entity objects.

Step 7 :

All the attributes belongs to the EO will be listed. Click Next

Step 8:

You can change and add settings for every attribute you required. Primary key is required for Every table you create as EO otherwise it will force you to have RowId as primary key .  In Employess table EmployeeId is the primary key and thus it is made and click Next .

Step 9 :

You can create java classes for the EO .This java source contains the getter and setter for all the attributes. This is not a mandatory step as you can create any time once EO is created successfully.

Step 10 :

Optionaly You can check the Generate Default View Object option to generate view object for this EO. I will not check this as i will be telling in complete procedure on  how-to-create-adf-view-objects .  The same applies to Application Module also. Click Next and Finish.

Step 11 :

You can see the Emloyees EO in the package model.entity . you can also see the association created


Oracle ADF associations are business components that define a relationship between two Oracle ADF entity object definitions (the "source" and "destination" entity objects) based on sets of entity attributes (the "source" and "destination" attributes) from each. These can range from simple one-to-many relationships based on foreign keys to complex many-to-many relationships. For example, associations can represent:
  • The one-to-many relationship between a customer and all orders placed by that customer
  • The one-to-one relationship between a product and its extended description (if these are represented by separate entity objects
  • The many-to-many relationship between products and the warehouses that currently stock them