I'm getting some exceptions while trying to save data to database from UI made with
JSF components. The exceptions are as follows:
exception
javax.servlet.ServletException
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)
org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
root cause
java.lang.IllegalArgumentException
javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:124)
javax.faces.component.UISelectOne.matchValue(UISelectOne.java:141)
javax.faces.component.UISelectOne.validateValue(UISelectOne.java:114)
javax.faces.component.UIInput.validate(UIInput.java:634)
javax.faces.component.UIInput.executeValidate(UIInput.java:838)
javax.faces.component.UIInput.processValidators(UIInput.java:412)
javax.faces.component.UIForm.processValidators(UIForm.java:170)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:904)
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:342)
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:78)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
And UI code is as follows:
<%@page session="false" contentType="text/html;charset=utf-8"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
<html>
<head>
<title>Employee Registration</title>
<link rel="stylesheet" type="text/css" href="Css/Style.css"/>
</head>
<body>
<f:view>
<%@include file="Include.jsp"%>
<table border="0">
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<!-- form starts -->
<h:form id="empfrm" enctype="multipart/form-data">
<table width="100%">
<tr>
<td>
<h:outputText value="First Name :"/>
</td>
<td>
<h:inputText id="firstName" value="#{employee.firstName}" size="25" styleClass="textbox" required="true">
<f:validateLength maximum="50"/>
</h:inputText>
<h:message for="firstName" id="firstNameError" styleClass="error"> </h:message>
</td>
<td>
<h:outputText value="Last Name :"/>
</td>
<td>
<h:inputText id="lastName" value="#{employee.lastName}" size="25" styleClass="textbox" required="true">
<f:validateLength maximum="50"/>
</h:inputText>
<h:message for="firstName" id="firstNameError" styleClass="error"> </h:message>
</td>
</tr>
<tr>
<td>
<h:outputText value="Father's Name :"/>
</td>
<td>
<h:inputText id="father" value="#{employee.father}" size="25" styleClass="textbox" required="true">
<f:validateLength maximum="50"/>
</h:inputText>
<h:message for="father" id="fatherError" styleClass="error"> </h:message>
</td>
<td>
<h:outputText value="Mother's Name :"/>
</td>
<td>
<h:inputText id="mother" value="#{employee.mother}" size="25" styleClass="textbox" required="true">
<f:validateLength maximum="50"/>
</h:inputText>
<h:message for="mother" id="motherError" styleClass="error"> </h:message>
</td>
</tr>
<tr>
<td>
<h:outputText value="Religion :"/>
</td>
<td>
<h:selectOneMenu id="religion" value="#{employee.religion}" styleClass="selectOneMenu">
<f:selectItem itemValue="Islam" itemLabel="Islam"/>
<f:selectItem itemValue="Hindu" itemLabel="Hindu"/>
<f:selectItem itemValue="Christian" itemLabel="Christian"/>
<f:selectItem itemValue="Buddhist" itemLabel="Buddhist"/>
<f:selectItem itemValue="Other" itemLabel="Other"/>
</h:selectOneMenu>
</td>
</tr>
<tr>
<td>
<h:outputText value="Department :"/>
</td>
<td>
<h:selectOneMenu id="departmentid" value="#{employee.deptOID}" required="true">
<f:selectItems value="#{department.deptNames}"/>
</h:selectOneMenu>
</td>
<td>
<h:outputText value="Designation :"/>
</td>
<td>
<h:selectOneMenu id="designationid" value="#{employee.desigOID}" styleClass="selectOneMenu">
<f:selectItems value="#{designation.designations}"/>
</h:selectOneMenu>
</td>
</tr>
<tr>
<td>
<h:outputText value="Country"/>
</td>
<td>
<t:selectOneCountry value="#{employee.country}"/>
</td>
<td>
<h:outputText value="Blood Group :"/>
</td>
<td>
<h:selectOneMenu id="bloodgroupid" value="#{employee.bloodGroup}" styleClass="selectOneMenu">
<f:selectItem itemValue="apositive" itemLabel="A +ve"/>
<f:selectItem itemValue="anegative" itemLabel="A -ve"/>
<f:selectItem itemValue="abpositive" itemLabel="AB +ve"/>
<f:selectItem itemValue="abnegative" itemLabel="AB -ve"/>
<f:selectItem itemValue="bpositive" itemLabel="B +ve"/>
<f:selectItem itemValue="bnegative" itemLabel="B -ve"/>
<f:selectItem itemValue="opositive" itemLabel="O +ve"/>
<f:selectItem itemValue="onegative" itemLabel="O -ve"/>
</h:selectOneMenu>
</td>
</tr>
<tr>
<td>
<h:outputText value="Gender :"/>
</td>
<td>
<h:selectOneRadio id="genderid" value="#{employee.sex}" styleClass="selectOneRadio">
<f:selectItem itemValue="M" itemLabel="Male"/>
<f:selectItem itemValue="F" itemLabel="Female"/>
</h:selectOneRadio>
<h:message for="genderid" id="gendererror" styleClass="error"> </h:message>
</td>
<td>
<h:outputText value="Birth Date :"/>
</td>
<td>
<t:inputCalendar value="#{employee.dateofBirth}" renderAsPopup="true" renderPopupButtonAsImage="true"/>
<font color="#FF0000">*</font>
</td>
</tr>
<tr>
<td>
<h:outputText value="Join Date :"/>
</td>
<td>
<t:inputCalendar value="#{employee.joinDate}" renderAsPopup="true" renderPopupButtonAsImage="true"/>
<font color="#FF0000">*</font>
</td>
<td>
<h:outputText value="Privilege :"/>
</td>
<td>
<h:selectOneMenu id="privilegeid" value="#{employee.privilege}" styleClass="selectOneMenu">
<f:selectItem itemValue="admin" itemLabel="Admin"/>
<f:selectItem itemValue="user" itemLabel="User"/>
</h:selectOneMenu>
<h:message for="privilegeid" id="privilegeerror" styleClass="error"> </h:message>
</td>
</tr>
<tr>
<td>
<h:outputText value="Login ID :"/>
</td>
<td>
<h:inputText id="loginid" value="#{employee.userName}" size="25" styleClass="textbox">
<f:validateLength maximum="30"/>
</h:inputText>
<h:message for="loginid" id="loginerror" styleClass="error"> </h:message>
</td>
<td>
<h:outputText value="Password :"/>
</td>
<td>
<h:inputSecret id="passwordid" value="#{employee.password}" size="25" styleClass="textbox">
<f:validateLength maximum="30"/>
</h:inputSecret>
<h:message for="passwordid" id="passworderror" styleClass="error"> </h:message>
</td>
</tr>
<tr>
<td>
<h:commandButton id="save" value="Save" type="submit" action="#{employee.addEmployee}" styleClass="button"/>
</td>
</tr>
</table>
</h:form>
<!-- form ends-->
</td>
</tr>
</table>
</f:view>
</body>
</html>
Could anyone help me solve this?