45
Getting Started with Oracle ADF Oracle ADF Lab#1 Description: BISP is committed to provide BEST learning material to the beginners and advance learners. In the same series, we have prepared a complete end-to end Hands-on Beginner’s Guide for Oracle ADF. The document focuses on basic creating ADF application, view objects, view objects, Data Models, ADF Business Components, and exploring business services. Join our professional training program and learn from experts. History: Version Description Change Author Publish Date 0.1 Initial Draft Chandra Prakash Sharma 10 th Aug 2013 0.1 Review#1 Amit Sharma 10 th Aug 2013 www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 1

Oracle ADF Lab 1

Embed Size (px)

Citation preview

Page 1: Oracle ADF Lab 1

Getting Started with Oracle ADF

Oracle ADF Lab#1

Description:BISP is committed to provide BEST learning material to the beginners and advance learners. In the same series, we have prepared a complete end-to end Hands-on Beginner’s Guide for Oracle ADF. The document focuses on basic creating ADF application, view objects, view objects, Data Models, ADF Business Components, and exploring business services. Join our professional training program and learn from experts.

History:Version Description Change Author Publish Date0.1 Initial Draft Chandra Prakash Sharma 10th Aug 20130.1 Review#1 Amit Sharma 10th Aug 2013

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 1

Page 2: Oracle ADF Lab 1

ContentsHow To Create First Application in Oracle ADF :...............................................................................3

Building a Business Model with ADF Business Components :..................................................11Defining Attribute's Properties :................................................................................................18How to add Field Level Validation :...........................................................................................19................................................................................................................................................. 19How to run this application : .....................................................................................................20

Create View Objects .......................................................................................................................21View Criteria - Dynamic where clause ............................................................................................27

How to View Criteria :...............................................................................................................27Linking View Objects :.....................................................................................................................29

How to Create Linking View Objects :.........................................................................................29List of Values...................................................................................................................................36

How to add List of Values :.......................................................................................................36Define the Data Model for the Application Module :.........................................................................38

How To open Data Model for the Application Module :...........................................................38Adding Logic to your Entity Object :.................................................................................................39

How to Add Logic to your Entity Object :..................................................................................39Finding Hook-Points :......................................................................................................................43Exposing Your business Services to Other Systems :....................................................................43

How to Add Services Interface :................................................................................................43

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 2

Page 3: Oracle ADF Lab 1

How To Create First Application in Oracle ADF :Step 1 : Open JDeveloper and click on Application Navigator > New Application.

Step 2: Here give Application Name, select directory and give application package name. there is many type of application select Fusion Web Application(ADF), Then click on Next button.

Step 3 : Enter Project name and select available project technology, then click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 3

Page 4: Oracle ADF Lab 1

Step 4 : Check Default Package, Java Source Path, Output directory, Then click on Next button.

Step 4 : Enter Project 2 name and Click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 4

Page 5: Oracle ADF Lab 1

Step 5 : Click on Finish button.

After click on finish button there Fusion web application list. see below.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 5

Page 6: Oracle ADF Lab 1

After Click on Finish button then New Application create you can see below.

Step 1 : in This application how to add business layer see below.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 6

Page 7: Oracle ADF Lab 1

Step 2 : Click on Connection icon then open new window, on this window enter Connection name, Connection Type, User Name, Password, Driver, Host Name, SID, JDBC Port, Then click on Test button for test connection, Then Click on Ok button.

Step 3 : Click on Query button. Enter package name, Select table, Click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 7

Page 8: Oracle ADF Lab 1

Step 4 : Change the Package name and select available list then click on Next button.

Step 5 : Select Table for Read only View objects then click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 8

Page 9: Oracle ADF Lab 1

Step 6 : Click on Next button.

Step 7 : Checked Business components Diagram check box. then click on next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 9

Page 10: Oracle ADF Lab 1

Step 8 : Click on Finish button.

After finis, you can see diagram.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 10

Page 11: Oracle ADF Lab 1

Building a Business Model with ADF Business Components :

ADF Business Components and JDeveloper simplify the development, delivery, and customization of business applications for the Java EE platform.

Connect to the database

Retrieve data

Lock database records

Manage transactionsConnect To a Database :

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 11

Page 12: Oracle ADF Lab 1

Step 1:Click on Connect Database Link. See below.

Step 2 : Then Click on Create a Database Connection button.

Step 3 : Enter Connection name, User Name, password host Name, SID, JDBC Prot After that click on Test Connection Button for test. after that click on Ok button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 12

Page 13: Oracle ADF Lab 1

Step 4 : After then Click on Done button.

Build Business services :Step 1 : Click on Build Business services then click on Go to Substeps buttons.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 13

Page 14: Oracle ADF Lab 1

Step 2 : Click on Create Entity Object and Associations.

Step 3 : After then select Your model then click on Ok button.

Step 4 : Browse package name select schema then click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 14

Page 15: Oracle ADF Lab 1

Step 5 : Select Table view then Click on Next button.

Step 6 : Select Read only object, then click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 15

Page 16: Oracle ADF Lab 1

Step 7 : select Application module, Then click on Next button.

Step 8: Select Business Components Diagram, Then click on Next button.

Step 9 : After that click on Finish button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 16

Page 17: Oracle ADF Lab 1

After that you can see diagram see below.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 17

Page 18: Oracle ADF Lab 1

Defining Attribute's Properties :

Control functionality and behavior :

Mandatory

Default value

Refresh on updateDefault UI representation :

Label

Tooltip.

Format mask.

Control type.

Set the attribute property see below.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 18

Page 19: Oracle ADF Lab 1

How to add Field Level Validation :

Open JDeveloper select table, then go to attribute, then double click on any value . you can see below.

Declaration Validation :

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 19

Page 20: Oracle ADF Lab 1

Example : Employee Salary should be greater than 5000. Solution : Open JDeveloper select table, then go to attribute, then double click on any value .Click on Validation, Than click on New button. select Type, there is three tab available (Rule Definition, Validation Execution, Failure Handling )Select operator, Compare with , Enter Expression, Than click on ok button.

How to run this application :

Go to AppModule, right click than click on run link.. see below.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 20

Page 21: Oracle ADF Lab 1

Out put :

Create View Objects Oracle ADF view objects are business components that collect data from the data source, shape that data for use by clients, and allow clients to change that data in the Oracle ADF Business Components cache.Step 1 : Right click on AppModule, select ADF Business Components, than select View object, after that click on Ok.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 21

Page 22: Oracle ADF Lab 1

Step 2 : Enter then Name, Select the data source type. Then click on Next button.

Step 3 : Write Query Statement, for writing query click on Query builder button, then test the query and click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 22

Page 23: Oracle ADF Lab 1

Step 4 : Click on New button, then Enter Name, select Type Enter Value, Then click on Next button.

Step 5 : Click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 23

Page 24: Oracle ADF Lab 1

Step 6 : Click on Next button.

Step 7 : Check and set Attribute Settings, Then click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 24

Page 25: Oracle ADF Lab 1

Step 8 : Click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 25

Page 26: Oracle ADF Lab 1

Step 9 : Checked Application Module, Than click on Next button.

Step 10 : Then Click on Finish button.

After then run this application and see result, for run right click on AppModule and click on run. see below.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 26

Page 27: Oracle ADF Lab 1

View Criteria - Dynamic where clause Define multiple query conditions

Apply selected condition at runtime

Enable further view object reusability

How to View Criteria :

Double Click on EmployeeView in Value object > select Query > then go to down and find view

criteria and click on plus icon. see below.Step 1 :

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 27

Page 28: Oracle ADF Lab 1

Step 2 : Enter Criteria Name, Click on Add Item button, Add attribute, set Operator, ser Operand, add Parameter, Then click on Ok button.

After click on Ok button you can see . after then click on Save button.

After that Run this application for see result :

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 28

Page 29: Oracle ADF Lab 1

Linking View Objects :A view link allows us to create a relationship between view objects. The relationship can be one-to-one, one-to-many, many-to-one, or many-to-many. The View Link Wizard and Editor lets us specify source and destination view objects, and links them using attributes selected. To create a view link, we first need to have all the underlying view objects in place.A view link is also like a Oracle Forms Block relation, that allows you to join two objects. Join Query -Define at view object query. -Can be updatable. Master/Detail -define with view links. -The derail item belongs to the master.

How to Create Linking View Objects :Step 1 : Go to Application, then go to Value object, then Click on " New View Object link " . see below.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 29

Page 30: Oracle ADF Lab 1

Step 2: Enter Name , Then click on Next button.

Step 3 : Move Available Entity Objects, Then click on next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 30

Page 31: Oracle ADF Lab 1

Step 4 : Choose specific field which you want and click on move button, Then click on next button.

Step 5 : Check attribute setting, Then Click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 31

Page 32: Oracle ADF Lab 1

Step 6 : Check Query and click on Next button.

Step 7 : Check Query, there is use join table.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 32

Page 33: Oracle ADF Lab 1

Step 8 : Check bind Variables. Then click to Next button.

Step 9 : Click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 33

Page 34: Oracle ADF Lab 1

Step 10 : Mark Application Module and click on next button.

Step 11 : Check summary and click on Finish button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 34

Page 35: Oracle ADF Lab 1

After Run this application View result : See below.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 35

Page 36: Oracle ADF Lab 1

List of ValuesIn this post i will continue to enhance my previous post’s Employee Form and create my first List of Values (LOV) in Oracle ADF Form. Creation of LOV in ADF is as simple as in Oracle Forms. In this post i am going to create LOV for Department and Job entities. Do the following steps to create LOV in ADF.1) Add Departments and Jobs Entities2) Add View Objects for Departments and Jobs LOVs3) Create LOVs4) Finally Link LOVs to JSF Page

Define at the attribute level.

Gets list from another view object.

Define type of list and list behavior.

How to add List of Values :

Step 1 : Go to application, select Any value object, click on Attribute, go to down and click on this icon.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 36

Page 37: Oracle ADF Lab 1

Step 2 : Enter the list of Values Name, Select List data source, set list attribute, set UI Hints, Then click on O button.

After that run this application .

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 37

Page 38: Oracle ADF Lab 1

Define the Data Model for the Application Module :Associated with the root Application Module is the Transaction object, which provides this transaction context. From any (root or nested) Application Module, the user can retrieve the transaction object through a call to getTransaction(). In reality, getTransaction() first locates the root Application Module and then returns the transaction object from it.

How To open Data Model for the Application Module :

Open Apple action, Double click on AppModule , then select Data Model.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 38

Page 39: Oracle ADF Lab 1

ADF Business Components : XML and Java.

ADF Business Components and JDeveloper simplify the development, delivery, and customization of business applications for the Java EE platform. With ADF Business Components, developers aren't required to write the application infrastructure code required by the typical Java EE application to:

Connect to the database

Retrieve data

Lock database records

Manage transactions

ADF BC uses XML metadata to describe the objects. By default there are no java files created. In many cases you don't need java files. However if you want more complex logic you'll put that ina java file overriding default behavior. You can create java files for EO, VO and AM.

Adding Logic to your Entity Object : The Impl file is the one you all mostly use Then choose which default method to create. You only need to create the one you want to override.

How to Add Logic to your Entity Object :

Go to Application Then Go to Entity Object and Double click on any table, Then Select Java(given

right side screen) then click on Edit icon. See below.Step 1:

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 39

Page 40: Oracle ADF Lab 1

Step 2 : Checked Generate Entity Object class.

Step 3 : Click on Entity Object Class.

Step 4 : On Source page right click , Then select Source > Override Methods, see below. for adding override method.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 40

Page 41: Oracle ADF Lab 1

Step 5 : For Example : create remove Method, for create Remove method select Remove() method thenclick on Ok button. you can see below.

Step 6 : Write here code for print message .

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 41

Page 42: Oracle ADF Lab 1

Step 7 : After that run this application and see result.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 42

Page 43: Oracle ADF Lab 1

Finding Hook-Points :- Use Source > Override Methods to locate an event you want to inject code into You have Access to :

set/get for attributes

Transaction events

Creation /remove events

DML events- Similar to Oracle Forms Triggers.

Exposing Your business Services to Other Systems : - Create SCA/SDO interfaces to business services declaratively. - Automates creation of : - java interface : Define the service. - EJB 3.0 session bean : Implements the java interface. - WSDl file : describes the service's operations. - XML Schema Document(XSD) : Defines the service's data structures. - Integration with Oracle's SOA Suite.

How to Add Services Interface :

Go application > Then Go Value Object, Double click AppModule > Select Service

Interface(Available Right side), Then Click on Add Icon. see below.Step 1 : Select Value Object, Then Double Click on AppModule, Then Select Service Interface.

Step 2 : Enter web service name click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 43

Page 44: Oracle ADF Lab 1

Step 3 : Click on Next button.

Step 4 : Select Table, Checked check box which want to want then click on Next button.

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 44

Page 45: Oracle ADF Lab 1

www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 45