This article aims to provide detailed steps to develop a web-based application based on technologies in the JEE6 specs, i.e., JavaServer Faces 2.0 (JSF), Enterprise Java Beans 3.1 (Session Bean and Message-Driven Bean) and Java Persistence API (JPA) with the help of NetBeans IDE 6.8 as the development & deployment tool. The example in this tutorial creates a web application called "CustomerApp" that performs only the Retrieve and Update functions of CRUD on the customer records provided by the NetBeans Sample database served by the Glassfish built-in database server, JavaDB (Derby). In addition to the above-mentioned technologies from JEE6, PrimeFaces for JSF2 will also be used as the Ajax-based Framework for the Web UI portion which is lacking in the stack. So, this tutorial also discusses how PrimeFaces can be integrated into NetBeans IDE and to enable Ajax capabilities for Web projects.
The objective of this tutorial is to demonstrate the ease of using the various JEE6 technologies and putting them together to create an enterprise-ready web-based application. Although the application is developed for demo purposes, its architecture represents the best practices in developing an enterprise application, whereby modularity, scalability, and reusability are taken into consideration.
The architecture of the application is shown in the above diagram, where it is organized into various tiers: Presentation, Business, Data Access and Data, where each has an important role to play and is segregated from one another. This architecture encourages a clean separation of responsibilities, reusability, and scalability through the use of Enterprise Java Beans. With the use of JSF and JPA, GUI development becomes a breeze and developers are no longer bogged down by the tedious and error-prone chores of converting relational data to OO, which is natural in Java and vice versa. So, all-in-all, this demo not only demonstrates the use of the various JEE6 technologies, it also demonstrates the best-of-breed application architecture that can be used in a production system.
The rest of this article consists of the following sections:
- Tutorial Requirements
- Creating the Enterprise Application Project
- Creating the Entity Classes from the Database
- Creating the Enterprise Java Beans (Session & Message-Driven)
- Preparing the Web Project to use JSF 2.0 and PrimeFaces
- Creating the Customer Managed Bean
- Creating the Customer Listing Web Page
- Creating the Customer Details Web Page