This article shows how to integrate JSF2, PrimeFaces3, Spring3 and Hibernate4 Technologies. It provides a general project template for Java developers.
Also if Spring is not used for Business and Data Access layer, [url="http://www.onlinetechvision.com/?p=332"]JSF –PrimeFaces & Hibernate Integration Project[/url] can be offered.
Used Technologies :
JDK 1.6.0_31
Spring 3.1.1
JSF 2.1
Hibernate 4.1.0
Primefaces 3.1.1
MySQL Connector 5.1.17
MySQL 5.5.8
c3p0 0.9.1.2
Tomcat 7.0
Maven 3.0.2
STEP 1 : CREATE MAVEN PROJECT
A maven project is created as below. (It can be created by using Maven or IDE Plug-in).
[img]http://dl.iteye.com/upload/attachment/0077/4582/f9601065-8fdd-3922-b398-0cdde0024e6c.png[/img]
STEP 2 : CREATE USER TABLE
A new USER Table is created by executing below script:
STEP 3 : LIBRARIES
Spring, JSF, Hibernate, Primefaces, MySQL and c3p0 dependencies are added to Maven’ s pom.xml.
STEP 4 : CREATE USER MODEL CLASS
A new User Model Class is created.
STEP 5 : CREATE USER MANAGED BEAN CLASS
User Managed Bean is created.
STEP 6 : CREATE IUserDAO INTERFACE
IUserDAO Interface provides methods of Data Access Layer. The data access layer manages all the logic to persist and retrieve the data from database.
STEP 7 : CREATE UserDAO CLASS
UserDAO Class is created by implementing IUserDAO Interface.
STEP 8 : CREATE IUserService INTERFACE
IUserService Interface provides methods to process the business logic.
STEP 9 : CREATE UserService CLASS
UserService Class is created by implementing IUserService Interface.
STEP 10 : CREATE applicationContext.xml
Spring Application Context’ s content is shown as follows :
STEP 11 : CREATE faces-config.xml
JSF Configuration is shown as follows :
STEP 12 : CREATE web.xml
web.xml is configured as follows :
STEP 13 : CREATE index.xhtml
index.xhtml is created as follows :
[img]http://dl.iteye.com/upload/attachment/0077/4584/5d24ef18-d07b-35e8-a954-bf9e4b3f4160.png[/img]
STEP 14 : CREATE success.xhtml
success.xhtml is created as follows :
[img]http://dl.iteye.com/upload/attachment/0077/4586/dd2cd1fd-816c-305b-ac18-a6df9820a5b7.png[/img]
STEP 15 : CREATE error.xhtml
error.xhtml is created as follows :
STEP 16 : DEPLOY PROJECT
After OTV_JSF_Spring_Hibernate Project is deployed to Tomcat, index page can be opened via following URL :
http://ip:port/OTV_JSF_Spring_Hibernate_Project-1.0-SNAPSHOT/pages/index.jsf
REFERENCES :
[url="http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/"]Spring Framework Reference 3.1.x Documentation[/url]
[url="http://www.hibernate.org/docs"]Hibernate 4.x Documentation[/url]
[url="http://primefaces.org/documentation.html"]Primefaces 3.x Documentation[/url]
From:[url]http://www.onlinetechvision.com/?p=566[/url]