RichFaces component is getting rendered but broken - jsf

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.

Related

RichFaces and facelets combination not working

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.

How to separate head?

Here how look my .jspx files:
<?xml version='1.0' encoding='utf-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core">
<jsp:output omit-xml-declaration="true" doctype-root-element="HTML" doctype-system="http://www.w3.org/TR/html5"/>
<jsp:directive.page contentType="text/html;charset=utf-8"/>
<f:loadBundle basename="my.pack.resource" var="r"/>
<f:loadBundle basename="my.pack.error" var="e"/>
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html utf-8"/>
<meta name="viewport" content="width=device-width"/>
<title> Some title </title>
<jsp:directive.include file="/temp/myLayout.jspf" />
</head>
<body>
<h:form>
<h:commandLink .........
</h:form>
</body>
</html>
</f:view>
</jsp:root>
In order to keep my view files clear and small
I would like to put all above and after body in
templates and include it in my .ispx files and pass title as parameter.
If anybody knows solution, please help.
EDIT
I have changed my view from .jspx to .xhtml, but my servlet filters now don't work.
Here my web.xml:
<?xml version = '1.0' encoding = 'windows-1252'?>
<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">
<context-param>
<param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
<param-value>*.xhtml;*.jsf</param-value>
</context-param>
<filter>
<filter-name>loginFilter</filter-name>
<filter-class>my.pack.filterpack.LoginFilter</filter-class>
</filter>
<filter>
<filter-name>remebermefilter</filter-name>
<filter-class>my.pack.filterpack.RemeberMeFilter</filter-class>
</filter>
<filter>
<filter-name>NoCacheFilter</filter-name>
<filter-class>my.pack.filterpack.NoCacheFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>loginFilter</filter-name>
<url-pattern>/view/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>remebermefilter</filter-name>
<url-pattern>/login/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>NoCacheFilter</filter-name>
<url-pattern>*.xhtml</url-pattern>
<dispatcher>FORWARD</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 mappings -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<error-page>
<error-code>500</error-code>
<location>/index.jsp</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/viewExp.jsp</location>
</error-page>
<listener>
<listener-class>my.pack.timer.MyJobManager</listener-class>
</listener>
</web-app>
This is one of the reasons why JSP(X) is abandoned, deprecated and succeeded by Facelets 4 years ago. JSP(X) doesn't offer easy templating capabilities in order to achieve this kind of requirements.
Just migrate to Facelets. Rename .jspx to .xhtml and replace <jsp:xxx> tags by <ui:xxx> tags. Your functional requirement is answered in 2nd example of How to include another XHTML in XHTML using JSF 2.0 Facelets?
Facelets is natively available in JSF 2.x. If you're still using JSF 1.x, then you can just install it separately as per its documentation.

JSF h tags not displaying [duplicate]

This question already has an answer here:
JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output
(1 answer)
Closed 5 years ago.
Using Netbeans to deploy a web app on Glassfish 3.1.2.2 and none of my h tags display on the web. For instance:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
<head>
<title>Draft Savvy Beers</title>
</head>
<h:form>
<h:body>
<h1>Search for beers</h1>
<p><strong>Would you like to search for a beer?</strong>
<h:inputText value="#{draftSavvyController.searchTerm}" />
<h:commandButton value="#{draftSavvyController.searchforBeers}" /></p>
</h:body>
</h:form>
</html>
displays only the text, no input field or button. Using plain old html shows the fields and buttons obviously, but I can't access my controller this way. Here is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</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>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Let me know if I can provide anymore info. I'm pretty new at this...
Add this to your web.xml:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
I think the cause of the problem is that the request is not being passed through the FacesServlet.
The page URL did not match the url-pattern of the FacesServlet, thus it had not any chance to parse the tags.

JSF - RichFaces - IE9 re render failure

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.

h:selectOneMenu is not working with jsf2

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

Resources