PrimeFaces Hello World Example

 

PrimeFaces is a JSF UI framework that provides a set of useful JSF components such widgets, themes, autoComplete, ..

In this tutorial, we will use PrimeFaces in a JSF 2.2 application to create our first PrimeFaces Hello World project.

We will develop a registration mechanism by providing a simple form with some input fields and two buttons : a submit button to validate registration procedure and reset button to initialize the form.

 

1. Technologies used

  • JSF 2.2.8
  • PrimeFaces 4.0
  • Maven 3.0.5
  • Eclipse 4.4
  • JDK 1.7
  • Tomcat 7.0

 

2. Project structure

We create a simple JSF 2.2 application using Maven.

PrimeFaces-Hello-World-Example

 

3. JSF 2.2 dependencies

In addition to the JSF 2.2 libraries, we need to add primefaces dependency to use PrimeFaces features :

 

4. Model class

File :  User

 

5. Managed Bean

File :  RegisterController

 

6. JSF view

In order to use PrimeFaces components, we need to add the following namespace in the JSF page : xmlns:p=”http://primefaces.org/ui”

File :  index.xhtml

 

7. Web app configuration

File :  web.xml

We defined the index.xhtml as the home page.

 

8. Test It

URL : http://localhost:8080/PrimeFaces-Hello-World-Example/

 

Download source code

  • Amanda Nunes

    Thank you!