Home > JSF, Java, Richfaces > JSF and Richfaces configuration in Netbeans 6.x

JSF and Richfaces configuration in Netbeans 6.x

Introduction:

JSF (Java Server Faces) is an java based  framework  for developing web application . Also component library can be easily incorporated in to the JSF Application. I have listed the most used components libraries by the developers in the below.

But this articles explains the Installation guidelines of Richfaces with JSF in Netbeans 6.x. Additionally learn how to create a hello world application in JSF using Richfaces. I assume that you have the requirements which I had mentioned below

Requirements:

  • IDE – Netbeans 6.x
  • Tomcat 6.x/Glassfish/Jboss
  • JDK 1.5 and above

Configuration Steps:

Configuring Richfaces with JSF application in Netbeans6.x can be accomplished by 4 easy steps they are,

  1. Create the web application project
  2. Required jars(Library)
  3. Deployment descriptor configuration(web.xml)
  4. Hello world JSP page

Create the web application project:

First Let us create the web application project in JSF, by clicking the File in the menu and select New Project in the Netbeans6.x, I have stated an image for your clear understandings,

Once this window appears choose web application and click next. Now you will have the window which I had mentioned below

In the preceding window, Let us name and location of the project. Since my article explains the creation of  Hello world Application I have given the Name as HelloWorld and then click next. Now you will have the window which I had mentioned below

In the preceding window, Let us select the server(Your favorite Server) and click next

In the preceding window, Let us select the JavaServerFaces framework from the check box and click finish. So far we had created a JSF web application project in Netbeans6.x and next let us configure the Jar files for our web application.

Required jars(Library)

Click here to download the following required latest richfaces jars

  • richfaces-api-3.3.1.GA.jar
  • richfaces-impl-3.3.1.GA.jar
  • richfaces-ui-3.3.1.GA.jar

Deployment descriptor(DD) configuration(web.xml):


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 <context-param>
 <param-name>com.sun.faces.verifyObjects</param-name>
 <param-value>false</param-value>
 </context-param>
 <context-param>
 <param-name>com.sun.faces.validateXml</param-name>
 <param-value>true</param-value>
 </context-param>
 <context-param>
 <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
 <param-value>client</param-value>
 </context-param>
 <servlet>
 <servlet-name>Faces Servlet</servlet-name>
 <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
 <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
 <servlet-name>Faces Servlet</servlet-name>
 <url-pattern>/faces/*</url-pattern>
 </servlet-mapping>
 <session-config>
 <session-timeout>
 30
 </session-timeout>
 </session-config>
 <welcome-file-list>
 <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>

 <!-- Rich Faces configuration -->

 <!-- Specify the skin name -->
 <context-param>
 <param-name>org.ajax4jsf.SKIN</param-name>
 <param-value>laguna</param-value>
 </context-param>

 <!--Rich faces skin apply for the standard jsf component also-->
 <context-param>
 <param-name>org.richfaces.CONTROL_SKINNING</param-name>
 <param-value>enable</param-value>
 </context-param>

 <filter>
 <display-name>RichFaces Filter</display-name>
 <filter-name>Ajax4jsf</filter-name>
 <filter-class>org.ajax4jsf.Filter</filter-class>
 </filter>

 <filter-mapping>
 <filter-name>Ajax4jsf</filter-name>
 <servlet-name>Faces Servlet</servlet-name>
 <dispatcher>REQUEST</dispatcher>
 <dispatcher>FORWARD</dispatcher>
 <dispatcher>INCLUDE</dispatcher>
 </filter-mapping>

 <!--End of rich Faces configuration -->

</web-app>

Setup process of Primefaces in Netbeans6.x has been completed and now let us create a hello world page using Richfaces UI components. The following code should be conjured to do so,

Hello world JSP page:


<%--
 Document   : helloWorld
 Created on : Nov 22, 2009, 4:07:09 PM
 Author     : shunmuga
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>

<f:view>
<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <title>JSP Page</title>
 </head>
 <body>
 <h:form>
 <rich:panel style="position: relative; width: 400px;height: 150px;">
 <f:facet name="header">
 <h:outputText value="Hello world "/>

 </f:facet>
 <h:outputText value="Welcome to rich faces ..."/>
 </rich:panel>
 </h:form>

 </body>
</html>
</f:view>

By invoking the above code, we had created a Hello World demo application which contains a Richfaces panel, Now let us have a look on the snap of our Hello World application.

Screen Shot:

If you find this article is useful to you dont forget to give your valuable comments. Have a joyous day.

  1. November 25, 2009 at 3:25 am | #1

    If you use Maven, from Netbeans 6.8 Milestone release it even gives auto complete feature (link http://www.karthikeyanc.com/blog/index.php/2009/11/primefaces-ui-tags-support-in-netbeans-6-8-beta-plus/ ). Though it shows for PrimeFaces same holds good for RichFaces.

    Another JSF implementation to consider is http://openfaces.org/ and PrettyFaces for Bookmarkable URL

  2. November 25, 2009 at 9:27 am | #2

    Good post.

  3. Marcus
    November 25, 2009 at 11:34 pm | #3

    Good Post, but I thought Vaadin is GWT framework and not JSF based.

  1. No trackbacks yet.