Pre-Requisites
  1. J2SE 1.4 or higher (Depending on the version used)
  2. Servlet 2.x
  3. JSP 2.x
Refer your web-server documentation for the JSP and Servlet API version information.
Libraries
The Sun JSF implementation comes with two libraries one for API and other for Implementation. Just drop the libraries into the WEB-INF\lib folder of your web application.
Configuration Files
Create the faces-config.xml configuration file and configure it in the web.xml file. Below is the sample configuration of web.xml to plugin the JSF implementation.
 
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
 
Create properties files
Create the properties files and define the locale based messages. You can use the messages defined in the properties files directly in the JSF pages with simple declaration in the faces-config.xml file. Below is the sample declaration of the properties file.
<application>
<resource-bundle>
<base-name>com.yourcompany.app.resources.messages</base-name>  
<var>msg</var> 
</resource-bundle>
</application>

Create JSF Pages
Write the jsp pages which will present the results of the web application. Use the tag libraries provided by the JSF implementation to design rich UI. Use the expression language of JSF (EL) to put the power of JSF into your application.
Below is the way of including the tag libraries in to your JSP page.
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

Create Managed-Beans
Managed Beans, also called as backing-beans, are standard Java POJO bean whose methods and properties are available to the JSF pages using the JSF Unified Expression Language(EL). Using managed beans, which are generally used as controllers in JSF, you can easily manage the communication between client and server. All the public methods and properties (using standard getter and setter methods) can be accessible using the EL in JSF pages.
Define the managed beans that are required for the controller logic of your application. And configure the beans in the faces-config.xml file. Below is the sample configuration of the managed beans.
<managed-bean>
<managed-bean-name>BeanName</managed-bean-name>
<managed-bean-class>com.yourcompany.yourapp.beanpackage.BeanName</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
Define Navigation Rules
Navigation rules tells the container to choose the specified page. The controller, i.e. the backing bean will return the name of the navigation rule which specifies the page to be rendered. This can be achieved by making the managed bean operation return the string containing the name of the navigation rule and the navigation rule with that name is defined in the faces-config.xml file. Here is the sample configuration.
 
<navigation-rule>
<navigation-case>
<from-outcome>NavigationRuleName</from-outcome>
<to-view-id>/path/pageName.jsf</to-view-id>
</navigation-case>
</navigation-rule>
 

Like it on Facebook, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet

Is it true that the people whom the god loves die young?

Select from the given options which is abt to you.
No answer selected. Please try again.
Please select either existing option or enter your own, however not both.
Please select minimum 0 answer(s) and maximum 3 answer(s).
/polls/family-and-home/5955-is-it-true-that-the-people-whom-the-god-loves-die-young.json?task=poll.vote
5955
checkbox
[{"id":"20522","title":"Yes","votes":"44","type":"x","order":"0","pct":45.36,"resources":[]},{"id":"20523","title":"No","votes":"31","type":"x","order":"0","pct":31.96,"resources":[]},{"id":"20524","title":"Don't know","votes":"22","type":"x","order":"0","pct":22.68,"resources":[]}] ["#ff5b00","#4ac0f2","#b80028","#eef66c","#60bb22","#b96a9a","#62c2cc"] ["rgba(255,91,0,0.7)","rgba(74,192,242,0.7)","rgba(184,0,40,0.7)","rgba(238,246,108,0.7)","rgba(96,187,34,0.7)","rgba(185,106,154,0.7)","rgba(98,194,204,0.7)"] 350
bottom 200
No married couple wants to end up getting divorced. It is not like they have planned for it. They try to put up with their partners for as long as they
Due to our modern lifestyle, we feel that digestion related disorders are a common problem. Thus, we neither give importance to them nor seek any help
The bond of marriage brings the two people together. Initially, everything may seem okay and both of them slowly start discovering each other in the journey.
Why to choose Java? In the computer market, being able to use Java is a crucial knowledge. Java is a development terminology used to build compelling
DATABASE CONNECTIVITY This articles explains the need of database connectivity, the way it is achieved through Java using the JDBC(java database connectivity)
  Write your first simple java program.   First of all we need is a placewhere we can write your Java code. All Java programs are written using
Array of objects in Java Arrays are defined as block of continous memory locations which are arranged in one after another. Elements of the Array can
Synchronized block is alternative mechanism for "synchronized" methods.If we inherihate the non synchronized blocks either from base class or interface