Getting started with primefaces
Remarks#
PrimeFaces is an open source JSF framework. Its main features:
- 100+ components.
- Built-in Ajax based on standard JSF Ajax APIs.
- Push support via Atmosphere Framework.
- Mobile UI kit to create mobile web applications.
- 35+ built-in themes.
- Premium themes and layouts.
Versions#
Version | Release Date |
---|---|
0.8.1 | 2009-02-23 |
0.8.2 | 2009-03-26 |
0.8.3 | 2009-04-23 |
0.9.0 | 2009-06-15 |
0.9.1 | 2009-08-04 |
0.9.2 | 2009-09-07 |
0.9.3 | 2009-10-05 |
1.0.0 and 2.0.0 | 2010-02-15 |
1.0.1 and 2.0.1 | 2010-04-19 |
1.0.2 and 2.0.2 | 2010-05-31 |
1.1 and 2.1 | 2010-07-26 |
2.2 | 2011-02-07 |
3.0 | 2012-01-04 |
3.1 | 2012-02-06 |
3.2 | 2012-03-12 |
3.3 | 2012-05-29 |
3.4 | 2012-09-03 |
3.5 | 2013-02-04 |
4.0 | 2013-10-03 |
5.0 | 2014-05-05 |
5.1 | 2014-10-06 |
5.2 | 2015-04-08 |
5.3 | 2015-10-19 |
6.0 | 2016-06-07 |
Installing PrimeFaces
PrimeFaces can be used in all web applications based on Java Server Faces (version 2.x) which are run on Servlet Containers (e.g. Wildlfy or Tomcat or GlassFish).
There are several ways you can add PrimeFaces to your application.
Manually
Download the primefaces-{version}.jar
and add it to you classpath.
Maven
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>{version}</version>
</dependency>
For older versions (3.5 and below) you additionally have to add the PrimeFaces repository:
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>https://repository.primefaces.org</url>
<layout>default</layout>
</repository>
Gradle
repositories {
mavenCentral()
maven {
url "https://repository.primefaces.org"
}
}
dependencies {
compile "org.primefaces:primefaces:{version}"
}
NetBeans
PrimeFaces is bundled with the Java EE bundle of NetBeans. When you create a new “Java Web -> Web Application” you can select JavaServer Faces as framework. Then you configure JSF to use PrimeFaces components. It will copy the library to your project.
If you have created a Maven web application, you can select project properties and select JavaServer Faces as framework and then select PrimeFaces as mentioned above. Your pom.xml
will be modified to include the PrimeFaces dependency.
Hello world
After adding PrimeFaces to your JSF project, you can start using it in your pages using the namespace:
xmlns:p="https://primefaces.org/ui"
or, for PrimeFaces Mobile:
xmlns:p="https://primefaces.org/mobile"
This example should render a spinner:
<html xmlns="https://www.w3.org/1999/xhtml"
xmlns:h="https://java.sun.com/jsf/html"
xmlns:f="https://java.sun.com/jsf/core"
xmlns:p="https://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<p:spinner />
</h:body>
</html>