Version 2

         There are two ways to start a JSF application with RichFaces components with the NetBeans IDE. The first method is to create a simple JSF project within NetBeans, add RichFaces libraries and register RichFaces in web.xml. The second way is to create a Maven project, add JSF and RichFaces dependencies to its pom.xml, import the project into NetBeans, build it and run on the server. The following two examples demonstrate these methods.


         In the examples we will use the last version of the IDE, NetBeans 6.7, and Tomcat 6.0 server for running the application, so make sure that you have them downloaded and installed.

         The version of Maven used in the second example is 2.1.0.

    1. Simple JSF application with RichFaces

         Open NetBeans and create new project with JSF activated:

      • Navigate to File > New Project;

      • Select Java Web > Web Application and click Next;

      • Give the project a name, for example, testRichFaces;

      • On the next page configure the Tomcat 6 server and Java EE version (Java EE 5), press Next;

      • Check JavaServer Faces framework and click Finish to complete the project creation.


    Now press F6 to run the server. In the browser you should see “JavaServer Faces”.


    Next step is to add RichFaces libraries to the JSF project just created:

      • Right-click the project and follow to Properties > Libraries > Add Library > Create.
      • In the appeared dialog type RichFaces as the library name and select Components Libraries as the library type. Click OK.
      • Select just created RichFaces library and click Add Library. Then press OK.


    One more thing you need to do is to modify the web.xml, i.e. add filter mapping and skinning,  as it's described in the RichFaces Developer guide.


         Now you can use RichFaces components on the pages of your application. Let's  add, for instance, the <rich:calendar> component to the welcomJSF.jsp:

        • Open  welcomJSF.jsp;

        • Add the RichFaces tag library declaration at the top of the page:

                <%@ taglib uri="" prefix="rich"%>
        • Add <rich:calendar/> tag to the page.


      Run the server again (F6). Now in the browser window you should see the calendar control under the “JavaServer Faces” caption.

      2. JSF Maven Project with RichFaces

           First, create a Maven project as it's described in the “Integration of RichFaces into Maven Project” section of the RichFaces Developer guide. Just don't build the project. You'll be able to easily do it in NetBeans IDE.


           So next import the project to the NetBeans:

        • Follow to File > Open Project;

        • Select created jsf-app project and press Open Project.


      Now right-click the project and select the Clean and Build option that will perform the Maven 'mvn clean install' command. After building the project open the web.xml to configure it according to the listing in the Registering RichFaces in web.xml section of the RichFaces Developer guide.


            That's all. Now you can start using RichFaces components:

        • Open jsf-app/WebPages/pages/index.jsp;

        • Add the tag library declaration at the top of the page and some RichFaces component, for instance, <rich:calendar>. The page should look like this:

      <%@ taglib uri="" prefix="f"%>
      <%@ taglib uri="" prefix="h"%>
      <%@ taglib uri="" prefix="rich"%>
                <title>JSF Application with RichFaces built by Maven</title>
                     <rich:calendar />


      Finally run the application by right-clicking the project and selecting Run. It will open the browser window with the RichFaces calendar.