RichFaces
  1. RichFaces
  2. RF-3699

UITree.getTreeNode() returns always null

    Details

    • Type: Bug Bug
    • Status: Closed Closed (View Workflow)
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: 3.2.1
    • Fix Version/s: 3.3.0
    • Component/s: doc
    • Security Level: Public (Everyone can see)
    • Labels:
      None
    • Environment:
      Tomcat, JFS SUN RI, Facelets
    • Workaround Description:
      Hide

      Using the follow I got the data from the selected node:

      final Object rowKey = theTree.getRowKey();

      // this works
      final Object rowData = theTree.getRowData(rowKey);

      Show
      Using the follow I got the data from the selected node: final Object rowKey = theTree.getRowKey(); // this works final Object rowData = theTree.getRowData(rowKey);
    • Similar Issues:
      Show 10 results 

      Description

      If have a node selection listener on my rich:tree:

      <rich:tree switchType="server"
      nodeSelectListener="#

      {treeMgrt.onSelect}

      "
      >

      <rich:recursiveTreeNodesAdaptor roots="#

      {treeMgrt.roots}

      " var="item" nodes="#

      {item.nodes}

      ">

      <rich:treeNode>
      <h:outputText value="#

      {item}

      "/>
      </rich:treeNode>

      </rich:recursiveTreeNodesAdaptor>
      </rich:tree>

      If the onSelect(NodeSelectedEvent event) is called I do the following:
      ....
      final UITree theTree = this.getTree(event);
      final TreeNode treeNode = theTree.getTreeNode();
      ....

      treeNode is evey time null. Also If I use the method with rowKey. I have had a look into the basic implementation and found follow code:

      StackingTreeModel.java:

      public TreeNode getTreeNode() {
      if (isRowAvailable())

      { return null; }

      throw new IllegalStateException(
      "No tree element available or row key not set!");
      }

      The method isRowAvailable() returns true and the result is a null object.

        Activity

        Hide
        Nick Belaevski
        added a comment -

        There are no TreeNode instances created when tree adaptors are used. Use UITree#getRowData() to obtain current value instead

        Show
        Nick Belaevski
        added a comment - There are no TreeNode instances created when tree adaptors are used. Use UITree#getRowData() to obtain current value instead
        Hide
        Nick Belaevski
        added a comment -

        Not a bug

        Show
        Nick Belaevski
        added a comment - Not a bug
        Hide
        Thomas Wabner
        added a comment -

        Ok, but the documentation says nothing about that fact:

        /**

        • Return the data object representing the node for the currently
        • selected row key, if any
          *
        • @return {@link TreeNode} instance corresponding to the current row key
          */

          Maybe you could change this to this:

          /**
          * Return the data object representing the node for the currently
          * selected row key, if any.
          * <p>
          * If you use a tree adaptor this method returns always null. Please use #getRowData() instead.
          * </p>
          *
          * @return {@link TreeNode}

          instance corresponding to the current row key
          */

        In my mind the documentation should point out this. If no documentation gives me an hint it is an bug (not in code but then in the documentation).

        But is this not a problem with the interfaces or the complete component hirarchy?

        Of course, I don't know the right way to fix this.

        Show
        Thomas Wabner
        added a comment - Ok, but the documentation says nothing about that fact: /** Return the data object representing the node for the currently selected row key, if any * @return {@link TreeNode} instance corresponding to the current row key */ Maybe you could change this to this: /** * Return the data object representing the node for the currently * selected row key, if any. * <p> * If you use a tree adaptor this method returns always null. Please use #getRowData() instead. * </p> * * @return {@link TreeNode} instance corresponding to the current row key */ In my mind the documentation should point out this. If no documentation gives me an hint it is an bug (not in code but then in the documentation). But is this not a problem with the interfaces or the complete component hirarchy? Of course, I don't know the right way to fix this.
        Hide
        Gleb Galkin
        added a comment -

        Info about UITree#getRowData() is added to Dev. Guide

        Show
        Gleb Galkin
        added a comment - Info about UITree#getRowData() is added to Dev. Guide

          People

          • Assignee:
            Gleb Galkin
            Reporter:
            Thomas Wabner
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Due:
              Created:
              Updated:
              Resolved: