I am running a web application using RichFaces 4.1.0, mojarra 2.0.2 and apache tomcat 6.0.32.
My app runs well in all the different browsers except IE9.
It stops working in IE 9 and does not generate any javascript error or tomcat logs.
It fails whenever an a4j re-render operation happens.
I cannot use due to design constraints the meta tag to set the IE9 in compatiblity mode.
Below is my code and web.xml:
<h:body>
<h:form>
<rich:tabPanel switchType="client">
<rich:tab header="Overview">
<span>Total Number of Applications</span>
</rich:tab>
<rich:tab header="Options" onheaderclick="refreshOptions();" >
<h:outputText value="Logging Level:" />
<rich:select id="optionsLogLevel"
value="#{optionsBean.logLevel}"
required="true"
requiredMessage="Logging Level is required">
<f:selectItems value="#{optionsBean.logLevelsList}" />
</rich:select>
</rich:tab>
</rich:tabPanel>
<a4j:jsFunction name="refreshOptions"
action="#{optionsBean.refreshOptions}"
render="optionsLogLevel" execute="#this" />
</h:form>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableEarlyMissingResourceLibraryDetection</param-name>
<param-value>true</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>com.mitel.bpi.webadmin.model.BPIWebAdminContextListener</listener-class>
</listener>
You are likely hitting JAVASERVERFACES-2063, which breaks ajax communications in IE9 due to mis-implemented browser detection in jsf.js.
Upgrading to Mojarra >= 2.1.7 will likely fix your problems. Upgrade RichFaces while you are at it, 4.1.0.Final is quite long in the tooth now.
Related
I am trying to create a RichFaces application and because of some reasons I am using quite old versions i.e. I have to work with JSF 1.2 and RichFaces 3.0.1.
I have got the JSF 1.2 components working but when I am trying to create a simple page with a RichFaces component then component is getting render but it is broken. Below is actual and expected look and feel:
Expected (this from here, code is also present over there, just scroll little below over there, my code is coming below):
Actual:
I am getting menu options correctly but missing all those blue stuff and look-and-feel.
It looked to me that some CSS or images are missing, but I am using the RichFaces JAR and there is no mention in the tutorial that additional images/css would be required so I am ruling out this.
Then I thought that it could be container issue, I checked RichFaces technical requirements and for Apache Tomcat it should not be greater than 6.0 (Apache Tomcat 5.5 - 6.0), and I was working on 7.x, so I jumped that bingo I found the issue, but alas that I got same issue even when I deployed in Tomcat 5.5.
As per best of my knowledge I am having correct configuration details and all required JARs, but considering the situation I am having feeling that I am missing some configuration or something else.
richfaces_test_so.jsp:
<%#taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%#taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%#taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
<html>
<head>
<title>Add New User Form</title>
</head>
<body>
<f:view>
<h:form>
<rich:dropDownMenu value="File" direction="bottom-right" jointPoint="bl">
<rich:menuItem submitMode="ajax" value="New" action="#{helloBean.addUser}"/>
<rich:menuItem submitMode="ajax" value="Open" action="#{helloBean.addUser}"/>
<rich:menuGroup value="Save As...">
<rich:menuItem submitMode="ajax" value="Text File" action="#{helloBean.addUser}"/>
<rich:menuItem submitMode="ajax" value="PDF File" action="#{helloBean.addUser}"/>
</rich:menuGroup>
<rich:menuItem submitMode="ajax" value="Close" action="#{helloBean.addUser}"/>
<rich:menuSeparator id="menuSeparator11"/>
<rich:menuItem submitMode="ajax" value="Exit" action="#{helloBean.addUser}"/>
</rich:dropDownMenu>
</h:form>
</f:view>
</body>
</html>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>jsftest_tomcat_5</display-name>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Ajax4JSF -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</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>
<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>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>greeting.xhtml</welcome-file>
</welcome-file-list>
</web-app>
List of my JARs:
ajax4jsf-1.1.1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.1.jar
commons-dbcp-1.2.2.jar
commons-digester-1.6.jar
commons-el-1.0.jar
commons-fileupload-1.2.2.jar
commons-io-1.3.2.jar
commons-lang-2.1.jar
commons-logging-1.0.4.jar
commons-pool-1.3.jar
el-ri-1.0.jar
javax.el-api-2.2.4.jar
jsf-facelets-1.1.11.jar
jstl-1.1.0.jar
myfaces-api-1.1.5.jar
myfaces-impl-1.1.5.jar
richfaces-3.0.1.jar
tomahawk-1.1.6.jar
Could someone please help me point out if I am missing something. I have to work on RichFaces 3.0.1 and JSF 1.2, so please do not advise to work on latest versions.
I am using RichFaces and jsf 2.but when I moved to facelets some of
the rich component doesnt works for me. I am using
richfaces-api-3.3.4.Final.jar,
richfaces-impl-jsf2-3.3.4.Final.jar,
richfaces-ui-3.3.4.Final.jar.
tomcat version is 7.0.23
netbeans 7.3.1
I have configured the following details in web.xml
<web-app version="3.0" 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_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>
facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE
</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
<param-value>*.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Making the RichFaces skin spread to standard HTML controls -->
<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>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>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<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>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
faces-config.xml
<application>
<view-handler>org.ajax4jsf.application.AjaxViewHandler</view-handler>
</application>
index.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition>
<h:form id="studentFormId" binding="#{StudentDetail.initForm}">
<rich:panel id="Student" >
<f:facet name="header">
<h:outputText value="Student DOB" />
<rich:calender/>
</f:facet>
</rich:panel>
</h:form>
</ui:composition>
</html>
When I deploy after clean and build it shows the following error.
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.
config.ConfigureListener java.lang.RuntimeException: com.sun.faces.config.ConfigurationException:
CONFIGURATION FAILED! Must have aConstructor that takes in a ComponentConfig
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:273)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:842)
Caused by: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Must have a Constructor that takes in a ComponentConfig at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:449) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:214)
... 43 more
Caused by: javax.faces.view.facelets.FaceletException: Must have a Constructor that takes in a ComponentConfig
at com.sun.faces.facelets.tag.AbstractTagLibrary$UserComponentHandlerFactory.<init> (AbstractTagLibrary.java:330)
at com.sun.faces.facelets.tag.AbstractTagLibrary.addComponent(AbstractTagLibrary.java:558)
at com.sun.faces.facelets.tag.TagLibraryImpl.putComponent(TagLibraryImpl.java:114)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processComponent(FaceletTaglibConfigProcessor.java:588)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTags (FaceletTaglibConfigProcessor.java:368)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTagLibrary(FaceletTaglibConfigProcessor.java:321)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:270)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:437)
... 44 more
Caused by: java.lang.NoSuchMethodException:org.richfaces.taglib.AjaxValidatorHandler.<init> (javax.faces.view.facelets.ComponentConfig)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)
at com.sun.faces.facelets.tag.AbstractTagLibrary$UserComponentHandlerFactory.<init>(AbstractTagLibrary.java:328)
... 51 more
Can anybody find what mistake I have done here?
RichFaces 3.x and JSF 2 works fine. I'm using JSF 2.2 and RichFaces 3.3.4.Final.
You need to disable built-in JSF 2 facelets and add dependency on old jsf-facelets 1.1.15 (as per https://developer.jboss.org/wiki/RichFaces333andJSF20).
However, keep in mind that Mojarra has a bug when it looks for DISABLE_FACELET_JSF_VIEWHANDLER instead of javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER as per specification.
I wrote a simple jsf web app on eclipse. My web app works fine when I run it on tomcat 7 server in eclipse. Now I am in the process of deploying it to a server host name = cheetah.arvixe.com.
to do this I have exported my web app as a war file and have unzipped this war file in the public_html folder of the arvixe server.
When I go to my website on my browswer, i get a blank page. When I look at the page source I see my index.xhtml with the jsf tags. I want to know why my page is not showing. Any ideas?
Here is my index.html code:
<!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">
<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">
<ui:define name="content">
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Name"></h:outputText>
<h:inputText id="userid" value="#{user2.userId }"></h:inputText>
<h:outputText value="Password"></h:outputText>
<h:inputSecret id="password" value="#{user2.pincode}"
required="true" requiredMessage= "#{vm['loginBean.password']}">
<h:messages for="password" style="color:red" />
</h:inputSecret>
</h:panelGrid>
<h:commandButton value="Register" action="query_results"></h:commandButton>
</h:form>
</ui:define>
</ui:composition>
</html>
and here is my web.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<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_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Redlancelogin</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.xhtml</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<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>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
in my web-ing/lib i have the jsf-api.jar and jsf-imp.jar
please tell me why I keep getting a blank page when i deploy to the host server. Thank you in advance!!!!
I am try to setup JSF project with prime faces library
When I run this setup it shows be following error
org.apache.jasper.JasperException: javax.servlet.ServletException: null source
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:54
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
I did not able to find out reason behind it . following is by setup
Folloing are the library I included into web-inf/lib
1. jsf-api-2.0.3.jar
2. jsf-impl-2.0.3.jar
3. jstl-1.0.2.jar
4. primefaces-3.4.jar
Following are the entrires into web.xml file
<?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>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>primefaces.skin</param-name>
<param-value>none</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>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
com.nsf.ecap.web.base.ECapStartUpServlet
</listener-class>
</listener>
</web-app>
login.xhtml
<h:body>
<CENTER>
<h:panel header="Login Form">
<h:Form>
<h:PanelGrid columns="2" cellpadding="2">
<h:outputLabel value="UserName" for="#{loginBBean.userInfo.username}"> </h:outputLabel>
<h:inputText value="#{loginBBean.userInfo.username}" label="UserName"> </h:inputText>
<h:outputLabel value="Password" for="#{loginBBean.userInfo.password}"></h:outputLabel>
<h:inputSecret value="#{loginBBean.userInfo.password}"></h:inputSecret>
<h:commandButton value="Login" type="submit" action="#{loginBBean.doLogin}"></h:commandButton>
</h:PanelGrid>
<h:messages>
</h:messages>
</h:Form>
</h:panel>
</CENTER>
</h:body>
</html>
index.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<jsp:forward page="jsp/login/login.jsf"/>
</body>
</html>
"My JSP 'index.jsp' starting page"? Please block/ignore/throwaway that tutorial you're reading now. It's only completely confusing you and teaching you bad practices.
As to your list of libraries:
Folloing are the library I included into web-inf/lib
jsf-api-2.0.3.jar
jsf-impl-2.0.3.jar
jstl-1.0.2.jar
primefaces-3.4.jar
First of all, the JSTL version is wrong. It should be at least JSTL 1.1 or preferably 1.2. The EL (expression language, those ${}/#{}) things would otherwise fail to work. Remove jstl-1.0.2.jar and put jstl-1.2.jar in place.
Further it looks okay. It only surprises me that you've more than 2 years old JSF API/impl versions while you've a fairly recent (less than 2 weeks) PrimeFaces version. I'd align those JSF API/impl versions as well to be the latest available. It's currently already at 2.1.13 (note: it's now composed of only one JAR file javax.faces.jar instead of two JAR files).
As to your web.xml:
<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">
This is declared conform Servlet 2.5 spec which is over 6 years old already. Are you sure that you're running such an outdated container? Given the presence of the JSF and JSTL libraries, I assume that you're using Tomcat. The current Tomcat version, 7.x, exist more than 2 years already and is Servlet 3.0 compatible. You should declare your web.xml to match the highest supported version of the target container.
<web-app version="3.0" 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_3_0.xsd">
Further, those javax.faces.STATE_SAVING_METHOD and javax.faces.DEFAULT_SUFFIX entries represent the default values already. Just get rid of them to minimize noise.
As to your login.xhtml:
<h:Form>
<h:PanelGrid columns="2" cellpadding="2">
Tag names are case sensitive. The <h:Form> and <h:PanelGrid> doesn't exist at all. It are <h:form> and <h:panelGrid>.
<CENTER>
While not immediately a problem, but this HTML element is deprecated since 1998 in favor of CSS. Also, seeing it in uppercased flavor instead of <center>, which is very typical for pre-90's HTML style, doesn't give me the impression that you're reading the most recent and right books/tutorials to learn web development. You should assure that your learning resources are up to date.
As to your index.jsp: this is completely useless. Remove it altogether. Just change your web.xml from
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
to
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
and this way login.xhtml will show up as "home page" when you access / in your webbrowser. Note that you shouldn't and don't need *.jsf URL pattern anymore.
See also:
Our JSF wiki page - at the bottom you can find decent JSF 2.0 resources
Recently we migrated to jboss-6.0.0.Final wiith richfaces-3.3.3.Final and jsf-2.0. After deployment we found the <h:selectOneMenu/> is not working properly if selectItems has the attribute 'noSelectionLabel' even <s:convertEnum/> is passed to the component. For example
<h:selectOneMenu id="gender" value="#{user.gender}">
<s:selectItems noSelectionLabel="Select Gender"/>
<f:selectItems value="#{user.genderTypes}" />
<s:convertEnum />
</h:selectOneMenu>
public Map<String, Gender> getGenderTypes() {
Gender[] values = Gender.values();
Map<String, Gender> genderTypes = new LinkedHashMap<String, Gender>(values.length);
for (Gender gender : values) {
genderTypes.put(gender.toString(), gender);
}
return genderTypes;
}
If value is not provided to this element, on page submit I am getting an error that
"Constant 'Select Gender' is not found
on enum Gender"
.
Then I analysed JSF 2 is initialized under Mojarra-2.0. I changed this to Mojarra-1.2 in web.xml like this
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>Mojarra-1.2</param-value> </context-param>
After this I am getting the deployment error
Caused by:
java.lang.NoClassDefFoundError:
org/richfaces/context/PartialViewConextImpl
My web.xml
<?xml version="1.0" ?>
<web-app 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"
version="2.5">
<!-- RichFaces -->
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Suppress spurious stylesheets -->
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name>
<param-value>enable</param-value>
</context-param>
<!-- Added to force facelets to ignore comments -->
<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<!--
Change load strategy to DEFAULT to disable sending scripts/styles as
packs
-->
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
<!-- Seam -->
<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Facelets development mode (disable in production) -->
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>false</param-value>
</context-param>
<!-- JSF -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<!-- Session Timeout -->
<context-param>
<param-name>org.ajax4jsf.handleViewExpiredOnClient</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.DEFAULT_EXPIRE</param-name>
<param-value>86400</param-value>
</context-param>
<!-- This param is needed to change the JSF configuration of our WAR -->
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>Mojarra-1.2</param-value>
</context-param>
<!-- Faces servlet -->
<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>*.seam</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>Restrict raw XHTML Documents</display-name>
<web-resource-collection>
<web-resource-name>XHTML</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint />
</security-constraint>
<session-config>
<session-timeout>20</session-timeout>
</session-config>
</web-app>
How to resolve this?
Since JSF 1.2, there's a builtin enum converter. You do not need a custom converter. To represent a default selection without a value, just use <f:selectItem> without an itemValue. Also, since JSF 2.0 you do not necessarily need a SelectItem[], List<SelectItem> or Map<K, V> for <f:selectItems> anymore. Just an T[] or List<T> is also supported. There's even a var attribute so that the item label and value could be set with the properties of T.
So, this view:
<h:selectOneMenu value="#{bean.gender}" required="true">
<f:selectItem itemLabel="Select gender" />
<f:selectItems value="#{bean.genders}" />
</h:selectOneMenu>
with this model:
private Gender gender; // +getter +setter
public Gender[] getGenders() {
return Gender.values();
}
should work as good without much hassle.
I have noticed this aswell under slightly different circumstances. If you explicitly assign a converter to an inputelement and have null as value (noSelecrtion), it will for some weird reason send the label instead of the value to the converter. I go around the problem by using the forClass attribute of #FacesConverter, or using JSF default converters (the enum one works okay for me).