Prime Faces Hello World Example

In a very simple Java terminology, PrimeFaces is a rich JSF lightweight library with one jar, zero-configuration and no required dependencies. So PrimeFaces is very easy to integrate with our application, just add primefaces-X.jar and start working with its components. Primefaces is one of the most popular UI component libraries used by the Java developers.

If you are choosing UI framework for building the applications, then you should get a question of choosing the best framework for your companye, but why should we choose PrimeFaces apart from lot of existing UI frameworks?. Naming a few frameworks,

Here is the answer that keeps PrimeFaces far better than any other JSF component libraries with its some of following features,

PrimeFaces Feature 1

PrimeFaces Feature 2

PrimeFaces Feature 3

PrimeFaces Feature 4

  • Push support via Atmosphere Framework.
  • Mobile UI kit to create mobile web applications for hand held devices.
  • Full integration with JQuery allows to leverage lots of JQuery libraries.

And also below graph indicates the users adopting PrimeFaces for their development has steady growth.

PrimeFaces Usage
And one of the good comments by user on PrimeFaces is unique because it pushes JQueryUI to the browser via Ajax. So as you can see there are several good reasons to consider seriously using PrimeFaces. Let’s see how to add it to a Web application.

Installation Setup for PrimeFaces

As mentioned earlier, PrimeFaces has a single jar called primefaces-version.jar. There are two ways to download this jar, you can either download from PrimeFaces homepage or if you are a maven user you can define it as a dependency.

  1. Download manually PrimeFaces from or
  2. Define the dependency in your Maven’s pom.xml

By manual Implementation(Normal build without Maven)

  1. Download JSF 2 jars from
  2. Place the jsf-api-2.0.3.jar, jsf-impl-2.0.3.jar and jstl-1.0.2.jar jars in WEB-INF/lib folder.
  3. Also place primefaces-2.2.RC2.jar in WEB-INF/lib folder.

By Maven Implementation

Add JSF 2 and PrimeFaces dependencies in pom.xml.

<project xmlns="" xmlns:xsi=""
    <name>primefaces Maven Webapp</name>

            <name>Prime Repo</name>


        <!-- PrimeFaces -->

        <!-- JSF -->




        <!-- EL -->


Folder Structure

Folder structure for this project would look like this.

Primefaces folder structure

JSF Configuration File

The following is the deployment descriptor web.xml for configuring the JSF servlet.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi=""
    id="WebApp_ID" version="2.5">

  <display-name>PrimeFaces Web Application</display-name>
    <!-- Change to "Production" when you are ready to deploy -->

    <!-- Welcome page -->

    <!-- JSF mapping -->
        <servlet-name>Faces Servlet</servlet-name>

    <!-- Map these files with JSF -->
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-name>Faces Servlet</servlet-name>


PrimeFaces does not require any mandatory configuration and follows configuration by exception pattern of Java EE. Here is the list of all configuration options defined with a contex-param such as


Below table shows configuration options

PrimeFaces Configurations Options

Add PrimeFaces to a Web Page

  • Add PrimeFaces declaration
    • PrimeFaces namespace is necessary to add PrimeFaces components to our page.
    • xmlns:p=
  • And for PrimeFaces Mobile, the namespace would be
    • xmlns:p=


<html xmlns=""
<b> Choose number : </b><p:spinner/><br/>
	<b> Choose date : </b><p:calendar/><br/>

When you run the above example, you will see PrimeFaces Editor in web page.

PrimFaces Hello World Example Demo

In the next article , we will try integrating with EJB and exposing more on JQuery Libraries. Stay tuned to our blog for more articles on PrimeFaces.

Download Source Code

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Pin It on Pinterest

Share This

Share this post with your friends!

Share This

Share this post with your friends!