Leveraging Third-Party Libraries to Create and Deploy Applications
to Oracle Cloud
Overview
- Have an Oracle.com account.
- Have already completed the following Oracle by Example (OBE)
tutorials: Signing Up for a Java Cloud Service,
Configuring NetBeans for Oracle Cloud, and Creating
and Deploying JSF/JPA Applications to Oracle Cloud.
- Have downloaded and unzipped the PrimeFacesFiles.zip
file.
Purpose
This tutorial covers leveraging third-party libraries to create
and deploy a web application to Oracle Cloud.
Time to Complete
Approximately 40 minutes
Introduction
Oracle Cloud is a public, enterprise, platform-as-a-service
(Paas) offering. Oracle Java Cloud Service provides support for
technologies associated with Java Platform, Enterprise Edition 5
(Java EE 5) and Java Platform, Enterprise Edition 6 (Java EE 6).
In this tutorial, you create and deploy an application that
leverages the open source PrimeFaces JavaServer Faces (JSF)
component suite library. JSF was designed to allow developers to
create new components while leveraging the JSF life cycle,
managed beans, and expression language. As a result, simply by
adding a third-party library to your project, you can create a
completely different look and feel and add functionality beyond
the core JSF libraries.
The NetBeans integrated development environment (IDE) supports
PrimeFaces out of the box. It is easy to create, deploy, and
test applications that use the component suite directly with a
local Oracle WebLogic Server instance and remotely with Oracle
Cloud.
Scenario
In this tutorial, you create a NetBeans project that provides support for PrimeFaces, add the necessary Facelets and supporting managed beans, test the application locally in a WebLogic Server 11g instance, and finally deploy and test the application in Oracle Cloud.
Prerequisites
Before starting this tutorial, you should:
Creating a PrimeFaces Project
In this section, you create a NetBeans project that leverages
the PrimeFaces component suite.
Select File > New Project.
In the New Project dialog box, perform the following steps:
a. Select Java Web from Categories.
b. Select Web Application from Projects.
c. Click Next.
In the New Web Application dialog box, enter PrimeFacesCloud
as the project name and click Next.
On the Server and Settings screen, perform the following steps:
a. Select Oracle WebLogic Server 10.3.6 from the list.
b. Deselect the Set Source Level to 1.5 check box.
c. Click Next.
On the Frameworks screen, perform the following steps:
a. Select JavaServer Faces.
b. Select the Components tab.
c. Select the PrimeFaces component suite.
d. Click Finish.
You successfully created a NetBeans project with JSF 2.0 and PrimeFaces libraries.
Adding the Code to the Application
For this tutorial, the code needed to create the application
is provided in the included zip file. You copy the files to the
appropriate folders and packages.
Select Window > Favorites.
Right-click in the Favorites tab and select Add to
Favorites.
In the Add to Favorites dialog box, navigate to the
directory where you unzipped the source files and click Add.
For example, here the files are unzipped to C:\Temp\PrimeFacesApp.
Perform the following steps on the Favorites tab:
a. Expand the src folder.
b. Select the folders and Bundle.properties file.
c. Right-click the selected folders and file and select Copy.
On the Projects tab, right-click Source Packages
and select Paste.
Perform the following steps:
a. Expand the Web Pages folder.
b. Select the index.xhtml and welcomePrimeFaces.xhtml files.
c. Right-click the selected files and select Delete.
In the Confirm Multiple Object Deletion dialog box, click Yes.
On the Favorites tab, perform the following steps:
a. Expand web.
b. Select all the folders and the index.xhtml file.
c. Right-click the selected folders and file and select
Copy.
On the Projects tab, right-click Web Pages and
select
Paste.
Right-click the project and select New > Other to add a persistence unit to the project.
In the New File dialog box, select Persistence from Categories and Persistence Unit from File Types and click Next.
In the New Persistence Unit dialog box, perform the
following steps:
a. Select jdbc/HRDB as the Data Source.
b. Select None as the Table Generation Strategy.
c. Click Finish.
Note: If you do not see a jdbc/HRDB data source, you
need to complete the OBE titled Creating and Deploying
JSF/JPA Applications to Oracle Cloud.
In the persistence.xml file opened in the editor pane, select None as the Shared Cache Mode.
Right-click the project and select New > Other
to add a faces-config.xml file to the project.
Select JavaServer Faces from Categories and JSF Faces Configuration from File Types and click Next.
Click Finish.
Add the following content to the faces-config.xml file
above the closing faces-config tag:
<application>
<resource-bundle>
<base-name>/Bundle</base-name>
<var>bundle</var>
</resource-bundle>
</application>
This XML declares the location and name of the properties bundle file for the application.
Right-click Libraries and select Add
JAR/Folder to add a collection of PrimeFaces themes to
the project.
Browse to the directory where you unzipped the project files, select all-themes-1.0.9.jar, and click Open.
The PrimeFacesCloud application is now ready to be deployed to your WebLogic 10.3.6 instance and tested locally.
Deploying and Testing the Application Locally
- Section 1 displays current department information: department ID, department name, and department manager ID.
- Section 2 displays a list of employees in the current department. In this section, you can create a new employee, view a selected employee, edit an existing employee's data, or delete a selected employee.
- Section 3 displays a pie chart of employee salaries in
the selected department.
In this section, you deploy and test the application. Note:
This section assumes that you completed the OBE titled Creating
and Deploying JSF/JPA Applications to Oracle Cloud.
Right-click the project and select Deploy.

Open a browser and enter http://localhost:7001/PrimeFacesCloud.
The PrimeFaces human resources (HR) application has three sections.
Use the navigation buttons to select department ID 30
(Purchasing).
Click Create to add an employee to this department.
Enter the following data in the Create New Employees dialog box and click Save.
FirstName: Tim
LastName: Jones
Email: TJONES
PhoneNumber: 781.555.1234
HireDate: 12/4/1993
Salary: 2000
Note: The ID of your new employee is obtained from
the database and may be different.
Select the newly added row and click View.
Click Close.
With the new employee selected, click Edit.
Change the Email field to TAJONES and click Save.
With the row of the employee that you created selected,
click Delete.
Click Yes to confirm the deletion.
A menu in the upper-right corner of the application enables
you to choose the theme or "skin" for the application.
Select Dark-Hive.
The theme is immediately applied to the components and background color of the application.
Deploying and Testing the Application in Oracle Cloud
In this section, you modify the project to deploy it to Oracle
Cloud.
On the Projects tab, right-click the persistence.xml
file and select Open.
Enter database as the Data Source.
Right-click the project and select Properties.
Select Run from Categories.
Select Oracle Cloud Remote from the Server list and
click OK.
Right-click the project and select Deploy.
On the Oracle Cloud Remote Deployment tab, look for the URL that follows "Deployment was successful. Application is being opened at."
Copy the URL into a browser and sign in to your Oracle
Cloud account.
Repeat the tests that you performed in the section titled
"Deploying and Testing the Application Locally."
Summary
- Create a PrimeFaces project by using NetBeans
- Deploy the sample PrimeFaces application locally and
remotely to Oracle Java Cloud Service
- Oracle Cloud documentation
- NetBeans documentation
- Oracle WebLogic Server 11g documentation
- Oracle
SQL Developer documentation
- To learn more about Oracle
Cloud, refer to additional OBEs in the Oracle Learning Library
- Lead Curriculum Developer: Tom McGinn
In this tutorial, you learned how to:
Resources
Credits
To help navigate this Oracle by Example, note the following:
- Hiding Header Buttons:
- Click the Title to hide the buttons in the header. To show the buttons again, simply click the Title again.
- Topic List Button:
- A list of all the topics. Click one of the topics to navigate to that section.
- Expand/Collapse All Topics:
- To show/hide all the detail for all the sections. By default, all topics are collapsed
- Show/Hide All Images:
- To show/hide all the screenshots. By default, all images are displayed.
- Print:
- To print the content. The content currently displayed or hidden will be printed.
To navigate to a particular section in this tutorial, select the topic from the list.