Navigation





Standard JSF quick installation guides

,


Bookmark and Share

To install standard JSF library in your project first you have to import related JARs in your class path. To support all functionality of standard JSF you should import these JAR files (download JSF1.1 or JSF1.2 implementation).

jsf-api.jar
jsf-impl.jar
jstl.jar
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-logging.jar
commons-codec.jar
commons-discovery.jar

Be careful on including these JSF JARs. It is often that some of this JARs, especially jsf-api.jar and jsf-impl.jar, are included in some libraries imported automatically by IDEs to support JSF capabilities. It is a general rule for Java projects that for every JAR you have to verify if it already exists in some libraries or it already exists with different file name (different version, etc). After JARs are imported you have to add couple of lines in web.xml file.

<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/WEB-INF/faces-config.xml
</param-value>
</context-param>
<listener>
<listener-class>
com.sun.faces.config.ConfigureListener
</listener-class>
</listener>
<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>

If faces-config.xml file doesn't exist in WEB-INF folder you have to create it. If you are novice with JSF and you are not familiar with web.xml and faces-config.xml, you should read some quick JSF reference. You can find one of the beginners reference here.

For this configuration you should use 'faces' suffix instead of 'jsp' in you URL address. For example if you have 'index.jsp' file, you will access it with 'index.faces' URL. Empty template for JSP file is shown below:

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<f:view>
<head>
<title>Title</title>
</head>
<body>
<h:form>
YOUR CODE
</h:form>
</body>
</f:view>
</html>
Apache MyFaces

There are a couple of alternatives of standard JSF implementation. One of these is Apache MyFaces implementation. It is preferable if you use component libraries from MyFaces family (Tomahawk, Trinidad, Tobago ...). To use MyFaces instead of standard JSF library, import myfaces-api.jar and myfaces-impl.jar in place of jsf-api.jar and jsf-impl-jar. After that, change listener class in web.xml to org.apache.myfaces.webapp.StartupServletContextListener


Support The Project

Contact


Component Libraries