CHAPTER 4

Introduction to the Oracle Application
Development Framework

This chapter explores the concept of frameworks and development frameworks; it then explains ADF further and provides a basis for understanding how ADF guides and assists in the development work you perform in JDeveloper 10g. The chapter contains a general set of steps for using ADF; other chapters contain hands-on exercises that include more detailed steps for using ADF to create various types of code.

What is a Framework?

A frameworkbuilds upon the idea of code reuse by offering well-designed code libraries, documentation, and often development tools. It supplies acomplete system that accomplishes a specific task such as page flow( with the Struts framework) or business sevices (with the ADF Business Components framework). A framework provides the implementation of a high-level architecture.

Why Use a Framework?

Applications developed with a framework contain very little customized code compared to the code within the framework libraries. Therefore, code reuse makes application programming easier and faster.

A framework is a compromise between a 4GL and a 3GL. A 4GLs are primarily declarative programming tools with which you create objects and assign property values. The runtime code is derived from metadata you define in the builder and you have no chance to see or modify the runtime code outside the metadata. A 3GL requires you to write each line of code that creates the runtime program giving you ultimate control. A framework combines these two concepts allowing you to work in a declarative way but also allowing you to modify the basic functionality of the system.

A good framework delivers complete, working code as an infrastructure to your business code, as well as the flexibility to easily modify the framework’s behavior.

What is a Developmental Framework?

A developmental framework adds several layers around the idea of a framework and, in addition to base library classes of the framework, includes the following:

  • A developmental method The framework defines a set of steps used to create applications with the framework libraries. A developmental framework documents the method explicitly.
  • A developmental tool It will be supported by a software tool that helps complete the steps in the method.

Why Use a Developmental Framework?

The benefits are the same as those for a framework in general. You benefit from using a base set of framework libraries that are easily extensible and flexible, and save you from writing a large amount of foundation code for your application. The framework gives you a starting point for code and for development method.

Support for the Framework

Frameworks can be measured by the extent of user community support and the quality of information available.

What Is Oracle Application Development Framework?

The ADF is a full-featured development framework for creating application program code in JD. ADF contains all aspects of a true development framework discussed above.

The primary strength and uniqueness of ADF is in its handling of business services (data sources). ADF handles the complexity of binding the user interface components to the various sources of data

Who Will Use ADF?

The current trend in Java IDE tools is toward model-driven architectures (MDA), which allow a developer to graphically represent the underlying design of an application and then generate code from it.

ADF is aimed at all levels of Java developers. It is also targeted at the not-so-expert Java developer who is new to development languages or is migrating from another tool.

ADF Architecture Model

ADF is based on the J2EE design pattern Model-View-Controller (MVC). It will be covered in more detail in Chapter 7.

MVC

The MVC design defines three layers of application code:

  • ModelRepresents the data and values portion of the
    application
  • ViewRepresents the screen and user interface
    components
  • ControllerHandles the user interface events that occur as the
    userinteracts with the interface(view), controls
    page flow, and communicates with the Model layer.

ADF Layers and Components

ADF architecture divides its components into four layers as shown below:

Applications can exist in two main styles:

  • Java clientRuns code in a Java virtual machine on the client
    machine (applications and applets). The Java
    Foundation Classes (JFC) Swing library provides
    components such as buttons, containers, windows,
    etc.
  • Web ClientDisplays a user interface in the user’s web browser
    and is run on a web tier sercer (servlets, JSP
    pages).

Business Services

The Business Services layer provides a code layer for accessing data sources such as a database. It responsible for persistence – the physical storage of data for future retrieval and object-relational mapping(translating physical storage units such as rows and columns in relational database tables to object-oriented structures such as arrays of objects with property values). ADF is designed around the idea of flexibility.

ADF supports the following business services technologies:

  • EJB
    Standard J2EE structure for managing data files from within a runtime container, consisting of entity beans, session beans, and message-driven beans.
  • Web services
    Utility functions and other resources written by a provider that are available through an Internet address and can be incorporated into your application.

  • ADF Business Components
    Called BC4J in the previous release, provides components that allow developers to design and code business objects and business logic. It offers easy interaction with business data through SQL statements.
  • Java Classes
    You can code Java class files, also called Plain Old Java Objects(POJOs) or JavaBeans, that supply data stored in files or in Java objects. TopLink utilities provide flexible mapping and persistence services to these Java classes.

Model

The Model layer supplies the connection mechanism from the View layer to the data access components in the Business Services layer. It receives instructions from the Controller layer as requests for data retrieval and updating. This layer supplies data from the Business Services layer and sends a request to the View layer to update the display.

The Model layer is composed of two aspects:

  • ADF Data Controls
  • ADF Bindings

ADF Data Controls

Data controls are definitions used to abstract one or more business services into a common layer. They appear as a list of interface components available to data model components. A data model is a representation of the business service objects available to a project.

You can also use the business components diagram to modify or display the application module data model as below.

The above data model contains two master view object instances:

  • LocationsView1
  • DepartmentsView1

It also contains a detail view object instance, DepartmentsView2 that links to LocationsView1.

Data controls standardize the interface to business services other than ADFBC. The properties of a data conrol (if any) are usually collections of values (like row sets).

Here are some of the user interface components available foe view object –level components such as LocationsView1 and DepartmentsView2.

Java ClientWeb Client
TableRead-Only Table

ComboBoxNavigation buttons

TreeInput Form

NavigationBarRead-Only Form

ScrollBarSelect Row Link

Here are some data model components that are available for attributes:

Java ClientWeb Client
TextFieldValue

ComboBoxLabel

CheckBoxText Field

ScrollBar Password Field

TextAreaList of Values

Data controls are available from the Data Control Palette, which appears automacically when you display a visual editor or select View | Data Control Palette.

In addition to data value components, the Data Control Palette also offers “ operations” such as Commit and Rollback to send the current data in the Model to the Business Services layer.

Dragging a component to the visual editor:

ADF Bindings

Bindings are code or definitions that declare which data from a business service is connected to a user interface control or structure. ADF Bindings act as the connection layer from the View components to Business Services components. Bindings are defined using XML files (created and maintained AUTOMATICALLY by actions in the JD IDE).

This will be discussed in more details in future chapters.

Controller

The Controller layer is used only for web client code. For a Web client, the Controller layer defines page flow – which page is presented when an action occurs on another page.

Struts

The Struts framework is an open source project of the Apache Software Foundation that is used for Controller layer functionality. More on this in Chapter 17.

View

This layer includes Java Client and Web client technologies used to render user interfaces.

Java Client

This is a runtime alternative that runs code in a Java virtual machine on the client machine. It does not require application serversbecause all application code is stored and runs on the client machine. A primary function of Swing controls is to present user interface objects (an MVC view aspect).

Web Client

ADF supports a number of web client view technologies that display in a browser. These are the most fully supported:

  • JSP technologyA popular J2EE coding stylethat combines HTML and JSP tags. You can also embed Java scriplets. JSP files run on an application server and usually output HTML to the client browser.
  • ADF UIX An Oracle framework that defines a page using XML code. A unique feature is its rich container model, which allows creation of a standard lokk-and-feel for an application. UIX has many features in common with JSP technology.

ADF Code Libraries

ADF provides a set of base libraries you can extend and customize. Since JD uses libraries for an application’s basic functionality, you will very rarely need to know the details about how the libraries work.

The main libraries consist of many proven technologies.

Some ADF Libraries

Here is a list of some of the libraries available in the Libraries node of the Project Properties dialog:

ADF Controller RuntimeADF Web Runtime

ADF Designtime APIBC4J Client

ADF EJB RuntimeBC4J EJB Client
ADF Model RuntimeBC4J EJB Runtime

ADF JSP Tab LibraryBC4J HTML

ADF TopLink RuntimeBC4J Struts Runtime

ADF UIX RuntimeJClient Runtime

The Project Properties dialog

ADF Development Method and IDE Support

The purpose of framework support in an IDE is to make the job of learning the framework easier and to allow you to create applications more quickly. The objective is to use the declarative tools to create as much application code as possible and spend the least amount of time writing custom code. This allows you to spend more time writing code that adds business value to the application and less time writing code for plumbing.

This section provides an overview of these steps using ADF and a description of the tools that support these steps.

The Steps

The following summarizes the high-level steps needed to create an ADF BC model and JSP view application.

  1. Create an application workspace using an application template
  2. Create the Business Services and Model layers
  3. Create the View and Controller layers
  4. Test, debug, and deploy the application
    I. Create an Application Workspace Using an Application
    Template

You do this using the Create Application Workspace dialog shown below.

New Gallery Item Filtering

The New Gallery dialog is shown below:

The ViewController project for this workspace would show New
Gallery categories and items that are applicable to the technologies
defined for the project as shown below:


Managing Application Templates

You can examine the definitions of the default templates and add your own templates by clicking the Manage Templates button or by selecting Tools | Manage Application Templates to display the Manage Application Templates dialog below.

II. Create the Business Services and Model Layers

After creating an application workspace with an empty Model project, you need to define the business services in that project. This is done using ADF wizards, dialogs, or modelers that create default objects that you can modify.

Wizards and Editors

1