Simple CRUD Web Application with JSF 2.1, PrimeFaces 3.5, EJB 3.1, JPA (ORM) / EclipseLink, JAAS , MySQL
In this tutorial, I will demonstrate the basics of building a simple CRUD Web Application with JSF 2.1, PrimeFaces 3.5, EJB 3.1, JPA 2 (ORM) / EclipseLink, JAAS, Maven 2, MySQL 5.
- NetBeans 7.2 IDE
- GlassFish V3 application server
- MySQL server
- Java EE 6 (JDK 1.6),
- Maven 2
(There is a good instruction on how to install Netbeans 7.2 http://netbeans.org/community/releases/72/install.html)
I will briefly outline the project here but later on I will write more details about the project under each sections and post them once they are available. If you have any suggestions for improving this article I would love to hear from you.
1- Creating ORM entity classes with Plain Old Java Objects and SQL tables for the project
2- Securing your web application with Glassfish security realms in JAAS
3- Writing the Enterprise Java Beans, Create, Read, Update and Delete (CRUD) operations with JPA 2 EclipseLink (ORM)
4- Lazy Loading / Pagination with JSF 2.1 / Primefaces 3.5 DataTable and Form Validations
5- Downloading PrimeFaces themes / creating and installing custom themes for the project and overriding PrimeFaces style sheets and using PrimeFaces layouts.
I have updated faces-config.xml file to fix a bug caused (after a validation error) due to the incorrect state of the input fields. Thanks to John for finding this error and kindly letting me know about it.
To fix problem we need to add this dependency to our project’s pom.xml file
<dependency> <groupId>org.omnifaces</groupId> <artifactId>omnifaces</artifactId> <version>1.4.1</version> </dependency>
and then add this code line to faces-config.xml file to register ResetInputAjaxActionListener as a phase-listener
<lifecycle> <phase-listener>org.omnifaces.eventlistener.ResetInputAjaxActionListener</phase-listener> </lifecycle>
(You can download this file! Source code is up to date.)
For more information please see Omniface’s website
Some screenshots from Simple CRUD web application, you can also try live demo (Username: Admin, Password:1234)
User listing page:
User creating and editing dialogue:
JSF 2.1, PrimeFaces 3.5, EJB 3.1, JPA (ORM) / EclipseLink, JAAS , MySQL, CRUD