i understand from similar question on the site that to avoid the default value i have to use wrapper class, so i changed my int to Integer but then i am getting nullpointerexception, i thought if u pass a null value to jsf it just shows it as an empty field. i am using glassfish 4.0. i am unable to understand why i am getting this exception
following is the exception i am getting
javax.el.ELException: /index.xhtml @23,66 value="#{userIdea.idea.empid}": java.lang.NullPointerException
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:174)
at javax.faces.component.UIInput.getValue(UIInput.java:291)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
The following is my jsf code snippet
Employee ID:
<h:inputText value="#{userIdea.idea.empid}" required="true"
requiredMessage="You must enter a Employee ID"
converterMessage="Employee ID must be a number" id="empid" />
Idea class snippet
private Integer empid;
public int getEmpid() {
return empid;
}
public void setEmpid(int empid) {
this.empid = empid;
}