troubleshooting Question

JSF Navigation problem from my welcome page

Avatar of demchris
demchrisFlag for Canada asked on
Java EEAutomotive
11 Comments1 Solution706 ViewsLast Modified:
I got problem with my JSF project when trying to submit a form that is in my welcome page. I developed small web for which I only have one page with tabPanel into it, for one of my tab, I have a form with submit button, now, whe I click on the submit button, my action listener is never call and I am redirect to http://index.page...

If I access the web site not using the welcome-file mechanisms but directly access my page (http://localhost:8080/Index.page) everything works fine.

I try either with the jsp-forward strategy and the dummy Index.page file on my root, both of them give me same result.

I'm using jsf 1.2, Facelets 1.1.14, RichFaces 3.3.1.GA

Thanks,

It looks like the naviation handler isn't properly initialize when we're forwarding to the Index.page with welcome mechanism.
I built small sample to reproduce the problem, here is the code :
 
Here is my web.xml
 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <description></description>
  <display-name></display-name>
  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
  </context-param>
  <context-param>
    <param-name>facelets.REFRESH_PERIOD</param-name>
    <param-value>2</param-value>
  </context-param>
  <context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <param-value>blueSky</param-value>
  </context-param>
  <context-param>
    <param-name>com.sun.faces.numberOfViewsInSession</param-name>
    <param-value>30</param-value>
  </context-param>
  <context-param>
    <param-name>org.richfaces.CONTROL_SKINNING</param-name>
    <param-value>enable</param-value>
  </context-param>
  <filter>
    <display-name>Ajax4jsf 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>
  <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>*.page</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>/index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
 
Here is my faces=config.xml:
 
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xi="http://www.w3.org/2001/XInclude"
 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-facesconfig_1_2.xsd">
 <managed-bean>
  <managed-bean-name>contact</managed-bean-name>
  <managed-bean-class>com.cdsolutionsinfo.jsftest.contact.ContactHandler</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>
 <application>
  <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
 </application>
</faces-config>
 
And here is the Index.xhtml :
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j">
 
	<ui:composition template="/template/common.xhtml">
		<ui:define name="pageTitle">Welcome</ui:define>
		<ui:define name="content">
			<rich:tabPanel switchType="ajax">
				<rich:tab label="One">
					<h:outputText value="Bla Bla" />
				</rich:tab>
				<rich:tab label="Two">
					<h:outputText value="Bla Bla" />
				</rich:tab>
				<rich:tab label="Contact">
					<h:form id="contactForm">
						<div class="required">
							<h:outputLabel value="Nom :" for="name"/>
							<h:inputText id="name" value="#{contact.name}" required="true"/>
							<h:message for="name"/>
						</div>
						<div class="required">
							<h:outputLabel value="Courriel :" for="email" />
							<h:inputText id="email" value="#{contact.email}" required="true">
							</h:inputText><h:message for="email"/>
						</div>
						<div>
							<h:outputLabel value="Numéro de téléphone :" for="phone" />
							<h:inputText id="phone" value="#{contact.phone}">
							</h:inputText><h:message for="phone"/>
						</div>
						<div>
							<h:outputLabel value="Détail :" for="detail" styleClass="labelTextArea"/>
							<h:inputTextarea id="detail" value="#{contact.detail}" rows="5" cols="60"/>
						</div>
						<div align="center">
							<h:commandButton action="#{contact.contactService}" value="Envoyer"/>
						</div>
					</h:form>
				</rich:tab>
			</rich:tabPanel>
		</ui:define>
	</ui:composition>
 
</html>
ASKER CERTIFIED SOLUTION
demchris

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros