How to add RichFaces 3.3.x to maven based project

This article will walk you through the steps needed to user RichFaces in a Maven build environment.

 

The first step is to take a look at this article to configure Maven for using Jboss repository.


Note: if you using some older version (3.2.x, 3.1.x) consider the fact that some features just not exist there (pluggable skins, themes, constraint based validation)

Base dependencies (all versions)

    <dependency>
      <groupId>org.richfaces.ui</groupId>
      <artifactId>richfaces-ui</artifactId>
      <version>${richfaces.version}</version>
    </dependency>

${richfaces.version} - actual RF version used by your app.

Only richfaces-ui should be added to dependencies list and the api and impl libraries will be added as transitive dependencies. Also commons libraries - collections, beanutils, digester and logging will be added.

Base dependencies (3.3.3 version and later)

3.3.3 version comes with two richfaces-impl jars in order to provide jsf2 compatible version. So on top of the ui dependency above you have to add richfaces-impl of needed version

 

jsf 1.2

 

    <dependency>
      <groupId>org.richfaces.framework</groupId>
      <artifactId>richfaces-impl</artifactId>
      <version>3.3.3.Final</version>
    </dependency>

 

jsf 2:

 

    <dependency>
      <groupId>org.richfaces.framework</groupId>
      <artifactId>richfaces-impl-jsf2</artifactId>
      <version>3.3.3.Final</version>
    </dependency>

Themes and skins

To add pluggable skins provided by RichFaces you need next dependencies:

 

    <dependency>
      <groupId>org.richfaces.samples</groupId>
      <artifactId>laguna</artifactId>
      <version>${richfaces.version}</version>
    </dependency>
    <dependency>
      <groupId>org.richfaces.samples</groupId>
      <artifactId>glassX</artifactId>
      <version>${richfaces.version}</version>
    </dependency>
    <dependency>
      <groupId>org.richfaces.samples</groupId>
      <artifactId>darkX</artifactId>
      <version>${richfaces.version}</version>
    </dependency>

 

NOTE: skins - transitivelly depends on richfaces-impl. By default 3.3.3 verison will have 3.3.3.Final in dependencies. So you have to exclude it from skins or redefine scope to provided in order to use 3.3.3 version with richfaces-impl-jsf2.

 

And these to get themes:

 

        <dependency>
            <groupId>org.richfaces.samples</groupId>
            <artifactId>themes</artifactId>
            <version>${richfaces.version}</version>
        </dependency>    
        <dependency>
            <groupId>org.richfaces.samples</groupId>
            <artifactId>violetRays</artifactId>
            <version>${richfaces.version}</version>
        </dependency>    
        <dependency>

Bean Validation

You should also add dependencies to use constraint based validation. To get more info visit Hibernate Validator project pages. Different dependencies required in cases if you want to use 3.1.0 Implementation or JSR-303 based 4.0.2 implementation.

Misc third-party

Using NEKO filter you should add to your pom:

 

    <dependency>
      <groupId>nekohtml</groupId>
      <artifactId>nekohtml</artifactId>
      <version>${nekohtml.version}</version> 
      <scope>runtime</scope>
    <dependency>

 

It will also add's xerces as a dependency. So if you need to change xerces version - you should exclude it and add separatelly using:

 

    <dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
      <version>${xerces.version}</version>
    </dependency>

 

Using rich:insert component you should add jhighlight dependency:

 

    <dependency>
      <groupId>com.uwyn</groupId>
      <artifactId>jhighlight</artifactId>
      <version>${jhighlight.version}</version>
    </dependency>