How to add RichFaces 4.x to projects not based on maven

This article will guide you through the steps needed to configure RichFaces 4.2.0 Final in a project without Maven. If you are using Maven, you should follow this guide instead.

 

First thing you need to do is download RichFaces 4.2.0 Final from the Stable Downloads page. Once downloaded, unzip the package and check the artifacts directory. There you will find framework and ui directories, each one containing some of the RichFaces jars needed to build the application.

 

The list below shows all current jars distribuited. To build your project you only need four of them. From framework directory you must use richfaces-core-api-4.2.0.Final.jar and richfaces-core-impl-4.2.0.Final.jar. In the same way you are going to need richfaces-components-api-4.2.0.Final.jar and richfaces-components-ui-4.2.0.Final.jar from ui directory.


richfaces-4.2.0.Final/

     archetypes/

     artifacts/

          framework/

               richfaces-core-api-4.2.0.Final.jar 

               richfaces-core-api-4.2.0.Final-sources.jar

               richfaces-core-impl-4.2.0.Final.jar

               richfaces-core-impl-4.2.0.Final-sources.jar

          ui/

               richfaces-components-api-4.2.0.Final.jar

               richfaces-components-api-4.2.0.Final-sources.jar

               richfaces-components-ui-4.2.0.Final.jar

               richfaces-components-ui-4.2.0.Final-sources.jar

     docs/

     examples/

     ...

 

Copy the jars and paste them in your ../WEB-INF/lib/ directory of your project. Now all that is needed is to get the external dependencies.

 

External Dependencies

RichFaces needs a couple of external dependencies in order to work without problems in your application. These are cssparser.jar and sac.jar. Both of them can be downloaded from here and here respectively. Download both jars and place them inside ../WEB-INF/lib/ directory of your web project along with the richfaces jars.

 

Also RichFaces 4.x make use of the google-guava-r08 which is a core runtime dependency. It can be downloaded directly from its google code site at: http://code.google.com/p/guava-libraries/downloads . Download the zip package and extract guava-r08.jar and place it inside ../WEB-INF/lib/ directory of your web project.

 

Optional (Only for Client or Graph Validation)

If you are planning on using Client or Graph validation, you will need a couple of dependencies that are usually provided by Java EE 6 servers (i.e Jboss AS 6) If your server provides validation-api.jar and any implementation like hibernate-validators.jar, then you are good to go. If that is not the case, you might want to get those two jars and place them in your ../WEB-INF/lib/ directory for Client or Graph validation to work.

 

CDK annotation dependency (optional)

Now, there is an additional dependency that is needed only if you are creating/accessing some RichFaces components instance in your application actions or listeners. This dependency is used to define CDK annotations. If you think you will need it, you can download RichFaces 4.2 Final CDK annotation.jar from here and add it to your classpath.

 

And thats all, If you followed this steps, you will end up with a ../WEB-INF/ directory structure similar to the one below.

 

 

YourRichFacesProject/

     src/

     WebContent/

          META-INF/

          resources/

          WEB-INF/

               lib/

                    commons-annotations.jar

                    commons-beanutils.jar

                    commons-collections.

                    commons-digester.jar

                    commons-logging.jar

                    jstl.jar

                    richfaces-components-api-4.2.0.Final.jar

                    richfaces-components-ui-4.2.0.Final.jar

                    richfaces-core-api-4.2.0.Final.jar

                    richfaces-core-impl-4.2.0.Final.jar

                    guava-10.0.1.jar

                    cssparser-0.9.5.jar
                    sac-1.3.jar
               web.xml
               faces-config.xml
          index.hxtml
          ...
     ...

 

The highlighted entries are the RichFaces jars and its dependencies. Now you are ready to start developing with RichFaces 4.x