NPE in UIData.restoreDescendantComponentStates()
------------------------------------------------

         Key: MYFACES-520
         URL: http://issues.apache.org/jira/browse/MYFACES-520
     Project: MyFaces
        Type: Bug
  Components: Implementation  
    Versions: Nightly Build    
    Reporter: Peter Mahoney


I have a form which contains some inputText fields (one of which is required), 
and a dataTable which contains an inputText field and a selectOneMenu field, 
plus and inner dataTable containing inputText fields.

When a value is entered in the required inputText field, the form submits 
successfully. However, when the required field is left blank the following 
exception is thrown when processing the selectOneMenu field in the outer 
dataTable:
java.lang.NullPointerException
        at 
javax.faces.component.UIData.restoreDescendantComponentStates(UIData.java:221)
        at 
javax.faces.component.UIData.restoreDescendantComponentStates(UIData.java:233)
        at 
javax.faces.component.UIData.restoreDescendantComponentStates(UIData.java:233)
        at 
javax.faces.component.UIData.restoreDescendantComponentStates(UIData.java:233)
        at javax.faces.component.UIData.setRowIndex(UIData.java:191)
        at 
org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeInnerHtml(HtmlTableRendererBase.java:135)
        at 
org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeChildren(HtmlTableRendererBase.java:94)
        at 
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:319)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:444)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
        at 
org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
        at 
org.apache.myfaces.renderkit.html.HtmlGroupRendererBase.encodeEnd(HtmlGroupRendererBase.java:62)
        at 
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
        at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:349)
        at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:253)
        at 
org.apache.myfaces.taglib.UIComponentBodyTagBase.doEndTag(UIComponentBodyTagBase.java:55)
        at 
org.apache.jsp.cppolls_jsp._jspx_meth_h_panelGroup_0(cppolls_jsp.java:297)
        at 
org.apache.jsp.cppolls_jsp._jspx_meth_f_subview_0(cppolls_jsp.java:255)
        at org.apache.jsp.cppolls_jsp._jspx_meth_f_view_0(cppolls_jsp.java:134)
...

The following change to UIData seems to fix the problem:
...
            if (descendantStateIterator != null
                    && descendantStateIterator.hasNext())
            {
                System.out.println("has dsi");
                Object[] object = (Object[]) descendantStateIterator.next();
                childState = object[0];
                descendantState = object[1];

                if (component instanceof EditableValueHolder && childState != 
null)
                {
                    ((EditableValueHolderState) childState)
                            .restoreState((EditableValueHolder) component);
                }
            }
...

However, should this patch be necessary, or is there a problem elsewhere?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to