Chapter 6. Developer sample creation

The RichFaces CDK allows you to create samples easier as it has been discussed earlier
in the "Component usage overview" chapter.
Let's create a simple JSF project, called inputDate-sample for example,
with the help of the maven-archetype-jsfwebapp archetype.

It is necessary to proceed to your Sandbox directory
where you have created the <inputDate> component
and launch the following command (all in one line):

As easy to see a new directory inputDate-sample is created with the predefined JSF project structure:

Figure 6.1. The predefined JSF project structure

It should be pointed out that maven-archetype-jsfwebapp archetype creates
skeletons of the following files:
JSP page,
Facelets page,
managed bean already registered in the faces-config.xml,
complete deployment descriptor (web.xml).

Now it is necessary to edit a JSP page, managed bean skeletons, and add the proper dependency
to the pom.xml file of the inputDate-sample project.

6.1. JSP Page

You should proceed to the inputDate-sample/src/main/webapp/pages directory
and edit index.jsp file.
You should add a form with our <inputDate> component.

6.3. pom.xml

In order to use any component on a page (JSF, Facelets, RichFaces, etc.) you should
add necessary libraries to the JSF project. Sometime it takes a lot of time to get
all the dependencies of a particular library. You should also prevent versions conflict if the
library already exists on a server.
Now we are going to add necessary libraries to the JSF project, deploy and run project on
a server. Maven will help us.

Maven is a high-level, intelligent build and deployment tool
designed to take much of the hard work out of the build process.
In Maven's Project Object Model (POM) file we could declare necessary
dependent libraries and Maven plugins used to manage all parts of the build process.

Our <inputDate> component depends on JSF and RichFaces
libraries.
If you declare inputDate dependency in
the inputDate-sample project's POM
all the necessary libraries will be added automatically.
Therefore you need to delete richfaces-ui artifact out of
dependencies first and then add only one inputDate dependency:

Now it is possible to build the inputDate-sample project with the help of the following command:

mvn install

The final step is to deploy and run the project on a server.
One of the convenient features of Maven is the Jetty plugin.
Jetty is an open-source web server implemented entirely in Java.
In order to deploy and run the project on the Jetty you should take the following steps: