Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

How to integrate JSF with Spring

Posted by Pankil Patel on September 17, 2010

Step 1: Add required jars into your project

Here in this example we required:

  • commons-beanutils.jar
  • commons-collections.jar
  • commons-digester.jar
  • commons-el-1.0.jar
  • jboss-faces.jar
  • jsf-api.jar
  • jsf-impl.jar
  • standard.jar

If want to add richfaces support into your application then add below jar also:

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

Step 2: Edit your web.xml for jsf support

  • Add entry of context-param

<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml
</param-value>
</context-param>

  • Add FacesServlet and it’s servlet-mapping in last for their appropriate section.

<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>

If you are using Richfaces add also below filter and it’s mapping section into web.xml

<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>

Step 3: Add faces-config.xml, faces-managed-beans.xml and faces-navigation.xml files under WEB-INF folder

For Demo and more detail download

http://www.javaworld.com/javaworld/jw-11-2002/jsf/jw-1129-jsf.jar

You can use same faces-managed-beans.xml and faces-navigation.xml in this example as per your customization.

Best of luck………………………..

Advertisements

One Response to “How to integrate JSF with Spring”

  1. If you are using JBoss for deployment and you are getting Error:

    org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
    com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! com.sun.faces.lifecycle.LifecycleFactoryImpl cannot be cast to javax.faces.lifecycle.LifecycleFactory
    .
    .
    .
    .

    Solution:
    Remove your libs (jboss-faces.jar, jsf-api.jar, jsf-impl.jar) from your project and use libs from (\jboss-5.1.0.GA\server\default\deploy\jbossweb.sar\jsf-libs\) into your project

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: