ICEfaces
  1. ICEfaces
  2. ICE-8337

ace:rowExpansion - NullPointerException thrown when expanding all rows

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-3.0.0.GA, 3.1.0.BETA2, 3.1.0.RC1
    • Fix Version/s: 3.2
    • Component/s: ACE-Components
    • Labels:
      None
    • Environment:
      All

      Description

      Two buttons are setup to expand and contract all rows for the ace:dataTable. These buttons call an action method that uses the RowStateMap.setAllExpanded(true) and setAllExpanded(false).

      The first call to the Expand all button works correctly. If the same button is clicked again or if the Collapse All is clicked and then the Expand All button clicked again a NullPointerException is thrown and the app crashes.

      Stack trace:

      java.lang.NullPointerException
      at org.icefaces.ace.model.table.TreeDataModel.isRowAvailable(TreeDataModel.java:76)
      at javax.faces.component.UIData.isRowAvailable(UIData.java:343)
      at javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:499)
      at javax.faces.component.UIData.setRowIndex(UIData.java:473)
      at org.icefaces.ace.component.datatable.DataTable.setRowIndex(DataTable.java:393)
      at org.icefaces.ace.component.datatable.DataTableRowRenderer.encodeRowExpansion(DataTableRowRenderer.java:234)
      at org.icefaces.ace.component.datatable.DataTableRowRenderer.encodeRowExpansion(DataTableRowRenderer.java:303)
      at org.icefaces.ace.component.datatable.DataTableRowRenderer.encodeRow(DataTableRowRenderer.java:118)
      at org.icefaces.ace.component.datatable.DataTableRenderer.encodeTableBody(DataTableRenderer.java:228)
      at org.icefaces.ace.component.datatable.DataTableRenderer.encodeTable(DataTableRenderer.java:181)
      at org.icefaces.ace.component.datatable.DataTableRenderer.encodeEntirety(DataTableRenderer.java:142)
      at org.icefaces.ace.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:107)
      at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
      at org.icefaces.impl.renderkit.RendererWrapper.encodeChildren(RendererWrapper.java:49)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
      at org.icefaces.impl.context.DOMPartialViewContext.processPartial(DOMPartialViewContext.java:141)
      at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
      at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:390)
      at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)

        Activity

        Hide
        Arran Mccullough added a comment -

        Attached test case that shows issue.

        Steps to reproduce:

        • Load welcomeICEfaces.jsf
        • Click on Expand All button, all rows are expanded.
        • Click on Collapse All Button, all rows are collapsed.
        • Click on Expand All button again, NullPointerException thrown.
        Show
        Arran Mccullough added a comment - Attached test case that shows issue. Steps to reproduce: Load welcomeICEfaces.jsf Click on Expand All button, all rows are expanded. Click on Collapse All Button, all rows are collapsed. Click on Expand All button again, NullPointerException thrown.
        Hide
        Nils Lundquist added a comment -

        This case is due to a DataTable RowStateMap settting expansion to true for all the states that exist in the state map already, which during the first instance, is only the rows that have been rendered. The other row objects haven't had state created (state creation is lazy), so at first they aren't bugged; however once they have been rendered (and states have been created), and all states are expanded once more, the expanded flag causes at attempt at row expansion on the leaf row objects, who have no rows to expand, causing the NPE.

        The fix may be two-fold, fixing the chance for an NPE when this case occurs, and perhaps forcing eager state creation for tree cases, or modifying expansion state changes on tree cases to enable changes to the entire tree expansion state at intialization.

        Show
        Nils Lundquist added a comment - This case is due to a DataTable RowStateMap settting expansion to true for all the states that exist in the state map already, which during the first instance, is only the rows that have been rendered. The other row objects haven't had state created (state creation is lazy), so at first they aren't bugged; however once they have been rendered (and states have been created), and all states are expanded once more, the expanded flag causes at attempt at row expansion on the leaf row objects, who have no rows to expand, causing the NPE. The fix may be two-fold, fixing the chance for an NPE when this case occurs, and perhaps forcing eager state creation for tree cases, or modifying expansion state changes on tree cases to enable changes to the entire tree expansion state at intialization.
        Hide
        Nils Lundquist added a comment -

        Revision #30343
        Committed by nils.lundquist
        A minute ago
        ICE-8337 - Fixed NPE caused by programattic row expansion of leaf nodes.

        Show
        Nils Lundquist added a comment - Revision #30343 Committed by nils.lundquist A minute ago ICE-8337 - Fixed NPE caused by programattic row expansion of leaf nodes.

          People

          • Assignee:
            Nils Lundquist
            Reporter:
            Arran Mccullough
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: