Build a Web Application with JDeveloper

Build a Web Application with JDeveloper 11g Using EJB, JPA, and JavaServer Faces

3 Purpose

In this tutorial, you use Oracle JDeveloper 11g Version 11.1.1.2.0 to build a web application. To build the data model, you use the EJB diagrammer, utilizing EJB 3.0 and Java Persistence API (JPA). For the web client, JavaServer Faces (JSF) is used. A master-detail page, a query/edit page and a search page are included in the user interface.

Time to Complete

1 hour and thirty minutes

Topics

The tutorial covers the following topics:

 

Overview
Scenario
Prerequisites
Creating a Database Connection
Building the Data Model using EJB 3.0
Creating a New Project for the User Interface
Creating the Page Flow
Creating a Master-Detail JSF Page
Creating a Query Page
Creating a Search Page
Running the JSF Pages
Summary

 

Note: Alternatively, you can place the cursor over an individual icon in the following steps to load and view only the screenshot associated with that step. You can hide an individual screenshot by clicking it.

Overview

The application reflects the Model-View-Controller architecture. The model is provided by EJB Components, while the view and controller are provided by JavaServer Faces.You use the ADF Faces set of JSF-compatible components to build a richer web interface.

You first build the data model portion of the application. The Java Persistence API (JPA) provides a POJO persistence model for object-relational mapping. The Java Persistence API was developed by the EJB 3.0 software expert group as part of JSR 220, but its use is not limited to EJB software components. It can also be used directly by web applications and application clients, and even outside the Java EE platform, for example, in Java SE applications.

Enterprise JavaBeans (EJB) technology is the server-side component architecture for Java Platform, Enterprise Edition (Java EE) that encapsulates business logic. EJB technology enables rapid and simplified development of distributed, transactional, secure and portable applications based on Java technology.

The Java Persistence API is the standard API for the management of persistence and object/relational mapping. It provides an object/relational mapping facility for application developers using a Java domain model to manage a relational database. The Java Persistence API is part of the Java EE platform. It can also be used in Java SE environments.

In the tutorial, you implement a persistence model by developing Session and Entity beans. These beans use the EJB 3.0 annotations and JPA for model persistence.

  • EJB 3.0 entities represent persistent data from the database, such as a row in a customer table or an employee record in an employee table. Entities are also sharable across multiple clients. You use the Entity Manager API to create, update, delete and query the persistence model.
  • Session beans perform a distinct, decoupled task such as checking credit history for a customer.

You then create a master-detail form for viewing Departments and Employees information. Following this basic master-detail page creation, you create a query page to find a particular employee, and you then edit the employee's record. You also create a search page to search for a particular department.

While developing and testing the application, you use JDeveloper's embedded Java EE application server.

Scenario

You create persistence objects for the DEPARTMENTS and EMPLOYEES tables. The persistence objects are implemented as Entity Beans. Default getter and setter methods are created for department and employee data. These methods are implemented as part of a session bean. Then you create a Master Detail JSF page based on Departments and related Employees, a Query/Edit JSF page enabling a search for, and update of an employee's data and a search page that allows input of search criteria to find a particular department.

 

Prerequisites

1. Have access to or have installed Oracle JDeveloper 11g Version 11.1.1.2.0. You can download it from Oracle Technology Network.

2.Have access to or have installed the Oracle Sample Schemas, included with the Oracle 10g or Oracle 11g database.

The tutorial uses the HR schema. Specifically, the pages work with the DEPARTMENTS and EMPLOYEES tables.

Instructions for installing the HR schema and creating a connection to it in JDeveloper are available online at:

http://www.oracle.com/technology/obe/obe11jdev/11/common/connection11g.htm

3.Start JDeveloper by selecting Start > All Programs > Oracle Fusion Middleware > JDeveloper Studio 11.1.1.2.0

4.If the Migrate User Settings dialog box opens, click No.

If prompted for a User Role, choose Default Role.

view

Close the Tip of the Day window.

5.The JDeveloper IDE should now be displayed.

view

Creating a Database Connection

Java Database Connectivity (JDBC) is a standard API that is used for connecting a Java application to relational databases. JDeveloper uses a connection navigator to maintain connection information for your application. The connection navigator makes it easy to create, manage, and test database connections.

If you haven't already established a connection to the database, then do so by performing the following steps:

1. Click the Database Navigator tab on the Application Navigator. If the Database Navigator tab is not visible, choose View > Database > Database Navigator from the JDeveloper main menu.

2.Right-click the IDE Connections node and choose New Connection from the context menu.

3.In the Create Database Connection Dialog, in the first section enter the following values:

Connection Name HRConn
Connection Type Oracle JDBC
Username hr
Password hr
Save Password (checked)

Note: It is secure to deploy the password since it gets encrypted.

In the Oracle (JDBC) Settings section, enter the following values:

Driver thin
Host Name localhost
JDBC Port 1521

Choose the solution that applies best to your environment by completing one of the 2 following lines:

SID orcl
Service Name XE

4.Click Test Connection.

If the database is available and the connection details are correct, you see the word Success! displayed in the Status window.

If an error occurs, verify the connection settings, make any necessary changes, and then retest the connection.

If the connection is successful, click OK to complete the connection.

5.The Database Navigator should look like this:

You have just created a connection to the database that will supply data for the application you build in this tutorial.

The next section uses this connection.

 

Building the Data Model with EJB 3.0 Using the EJB Diagrammer

The data model provides data access and validation for an application. The data is always validated by the model, regardless of the client implementation. This cleanly separates the validation and business rules from the user interface.

In the next few steps, you create an application in JDeveloper and create a data model for your application.

Create a New Application and Project
Create the Persistence Model
Create the Data Model and test it
Run the Data Model outside Java EE container
Create ADF data controls from EJB Session Beans

Creating a New Application and Project

In JDeveloper, you always work with projects contained in an application. The application is the highest point in the control structure.

A JDeveloper project is an organization structure used to logically group related files You can add multiple projects to your application to easily organize, access, modify, and reuse your source code. In the Application Navigator, projects are displayed as the second level in the hierarchy, under the application.

It is considered best practice to use projects to separate the model code from the code written for the view. In this tutorial, you create one project for the EJB Components model, and later on a second one for the JSF views.

Before you create any components, you must first create an application and project. To do this, perform the following steps:

1. Click the Application tab to go back to the Application Navigator.

Click the New Application icon.

2.In the Create Application dialog box, enter the Application Name HR_EJB_JPA_App. No

Últimas Noticias

Actualmente aumentar la  productividad y la competitividad empresarial es cada vez una tarea...
https://listacasas.com Uno de los portales inmobiliarios más conocidos de Guatemala...
Nuevo proyecto realizado por Infoacp, una web en prestashop : https://wiwi-pc.es En wiwi-pc...
More inNoticias  

Documentos Recientes

Categorías

Linkedin Twitter Facebook Youtube
Copyright (c) InfoAcp 2013. All rights reserved. Mantenimiento Informático
Infoacp Empresa de Informática, diseño gráfico, desarrollo de aplicaciones de gestión, Odoo, Contratos de mantenimiento informatico
Diseño y soluciones TIC Infoacp S.L.
Murcia Murcia 30007 España
Localización: 37.9956589, -1.1284899
868 70 76 94
informática, diseño gráfico, reparación de ordenadores, reparación de portatiles, reparación de móviles, programas de gestión para empresas, odoo, desarrollo odoo, programacion odoo, contratos de mantenimiento informatico