Tuesday, May 19, 2015

Cont. ADF Sample App

The Application Overview page will be displayed in the center, and it will guide us with the
steps required to create an application. The overview screen will have the following options:
‹ Checklist: This option helps to track the progress of our application development.
‹ Java Files: This option is used to add any Java files to the project. It can be any
helper class or utility class that you want to add to your project.
‹ Page Flows: Initially you will have the following two configuration files available:
‰ faces-config.xml: Any configurations related to JSF go in this file.
Some of the ADF-related configurations are also added in this file.
‰ adfc-config.xml: This file will hold the ADF configurations.
‹ Managed Beans: The Bean class that is added to the ViewController project is
displayed here. These are JavaBeans that are managed by the ADF controller.
‹ Web Tier: This will list all the files, such as .javascript, .css, .jsp, .html, and
.jsf that are used in the view layer.
‹ Business Components: This option lists all the components, such as Entity, View,
Associations, View Link, Application Module.
‹ Binding Files: The data controls available for the projects are displayed in this
section.
‹ Offline Database: If you have any offline database objects created for the project,
those files will be listed in this section.
The Model project is empty and the ViewController project will have the WEB-INF folder
populated with the following XML files:
‹ adfc-config.xml
‹ faces-config.xml
‹ trinidad-config.xml
‹ web.xml

Our high-level goal is to achieve the following:
‹ Create business services for the Employee and Department objects.
‹ Expose the components through the data controls.
‹ Manage the Employee and Department information from a page.

Connect to a database
1. Click on the Create a Database Connection button from Show Overview in the
Application menu.
2. The Create a Database Connection wizard opens. You have the following two
options to create the connection:
‰ Application resources: This connection will be created only for the
current application.

‰ IDE Connections: This option will make sure that you are creating
the connection for the complete IDE, which is shared across multiple
applications.

3. Enter the value of Connection name as HRSchema, the username value as hr, and
the password value (this will be provided during the installation of Oracle XE 11g
Express Edition) to connect to the Oracle XE 11g Express Edition installed on your
machine.
4. Enter the value of Host name as localhost as you are running the DB locally; the
value of SID will be XE, and that of JDBC port will be 1521. These are all default
settings for the XE database.
5. Click the Test the connection button and make sure that you are seeing the
Success! message.
6. Click the OK button to create the connection.
7. you will see the connection added to the IDE Connections panel
The connection information will be stored in the connections.xml file for the application. For the IDE connection, you will havethe information stored in your $USER_DIR/o.jdeveloper.rescat2.model/connections/connections.xml file.

1. Create the connection for Application Resources as per the previous steps.
2. Click on the + (plus) sign to create a new connection.
3. Right-click on EmpDirectoryApplication and select New Connection.
4. Right-click on HRSchema and select Add to Application.
5. Drag HRSchema from IDE Connections and drop it on EmpDirectoryApplication
in the Database Navigator panel.
Build business services
You will have to click on Go to Substeps to list the sub steps involved in creating the business
components.
Before starting with the creation of the business components, we will initialize our Model
project. The Project Properties dialog is accessed by right-clicking on the Model project and
selecting the Project Properties menu option.

The Project Properties dialog will show a list of properties related to the project
that you need to configure.
3. Click on ADF Business Components and select Initialize Project for Business
Components. Usually when the business components are created, you will be
asked to select the database connection that will initialize the business components.
Selecting this option will skip the Initialize Project for Business Components dialog.
4. Click on the OK button. This will enable the DB connection for the Model project.
This action will create a .jpx file in the Model project
that will have the reference to the connection and other library import references.
Let us now create the business components using the following steps:
1. To create a new component, go to File | New; this can also be done by right-clicking
on the Model project, the directory, or the folder, and selecting New.
2. In the Business Tier section, select ADF Business Components.

3. A Create Business Components from Tables wizard will open up for you; select the
Entity Objects option.
4. Enter the package for your entity object as com.empdirectory.model.entity
and select HRSchema for your data source. You have an option to restrict the filter
by table, view, synonym, and others.
5. In the Name filter, enter EMP% so that the filter is applied to query the data source.
Click on Query to search for the filter in the database. Select the Auto Query option
to query when you type the filter.
6. Shuttle the EMP table to the selected list to create the entity object. Enter the name
of the entity object as EmpEO. The entity object will represent the row in the EMP
table. We will create the entity object to work with the database objects.
7. Click Next > to create a view object based on the entity object.
8. Name the package as com.empdirectory.model.view.
9. Move the available entity object to the Selected: list.
10. Enter the name as EmpVO
11. The next section will help you to create a query-based view object. The view object
can be based on an SQL query that will be used to display the read-only information
of the table. View objects without the entity object are read-only and don't update
the table. In this example, we don't have any query-based object, so we will skip this
section this time.
12. We will create the application module in the next section.

No comments:

Post a Comment