Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1922

AbstractTree - setting root to null causes NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.5
    • 1.3.7, 1.4-RC5
    • wicket
    • None
    • JDK 1.6.0_01

    Description

      I have TreeTable with some nodes, perform some filtering of them and update tree model. If result of filtering is nothing (empty Tree) I set setRoot(null) on the tree model. This send treeStructureChanged event to all listeners (to my TreeTable) with parameter TreeModelEvent which is constructed with null TreePath parameter. This cause NullPointerException in AbstractTree (implements TreeModelListener).
      I propose this fix:
      org.apache.wicket.markup.html.tree.AbstractTree

      /**

      • @see javax.swing.event.TreeModelListener#treeStructureChanged(javax.swing.event.TreeModelEvent)
        */
        public final void treeStructureChanged(TreeModelEvent e)
        {
        // empty root
        if(e.getTreePath() == null) { invalidateAll(); }


        else {
        // get the parent node of changed nodes
        TreeNode node = (TreeNode)e.getTreePath().getLastPathComponent();

      // has the tree root changed?
      if (e.getTreePath().getPathCount() == 1 && node.equals(rootItem.getModelObject()))

      { invalidateAll(); }

      else

      { invalidateNodeWithChildren(node); }

      }
      }

      Attachments

        Activity

          People

            knopp Matej Knopp
            vlastimil.dolejs Vlastimil
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: