3 Replies Latest reply on Mar 23, 2007 12:32 PM by andrew.rw.robinson

    Tree selection is always remembered?

    andrew.rw.robinson

      I am using multiple selection for the tree nodes and using the selection as a toggle as opposed to single selection. So, in my node selection listener, I have added/removed the TreeRowPath to a set of selected nodes in my backing bean.

      Then I remove the tree selection from the UITree (set the TreeState's selected value to null), and add that node to the ajaxKeys set in the UITree to make sure it is re-rendered.

      This seems to work, but on further AJAX submits (by other controls, not just by the tree, with ajaxSingle=true), I am getting a node selection event of the node that I had selected earlier (the tree keeps re-firing the same node selection).

      How can I get the tree to "really" forget that the node was selected and that there is no current selection. I am using the following flags:

      switchType="ajax"
      ajaxSubmitSelection="true"

      Thanks

        • 1. Re: Tree selection is always remembered?
          andrew.rw.robinson

          Looks like I may get no help on this issue, but will try to provide updates. With the client debugging, I found the potential issue. The selected node is stored in the "[treeID]:input" control. This control is not always rendered in the response as seen here:

          debug[9:45:44,077]: call getElementById for id= testForm:testTree:input
          error[9:45:44,078]: New node for ID testForm:testTree:input is not present in response

          As a result, the existing one is left in the page which still has the value of the last submitted node. Therefore, this value is included in all future AJAX requests, and during the decode phase of the tree, the tree thinks that the node has be re-selected every time.

          I will keep looking into this to see if there is a hack/work-around to force this element to be refreshed, and at the very least I can use the oncomplete to clear the input value. This is the culprit HTML element:
          <input id="testForm:testTree:input"
          name="testForm:testTree:input"
          value="testForm:testTree:H:PagedTreeNode.movePrevious" type="hidden">


          • 2. Re: Tree selection is always remembered?
            andrew.rw.robinson

            Some more information

            The TreeRendererBase.java at line 389 has this code:

            if (value != null) {
             variables.setVariable("selectionId", value);
             } else if (rowKey == null) {
             variables.setVariable("selectionId", "");
             }
            

            What happens is that when the tree is AJAX rendered, and the selection has been cleared, the rowKey is always != null for each iteration of this code and the value is always null (since the selection has been cleared). As a result, "encodeSelectionStateInput" method never encodes the INPUT element as it only renders it if the selectionId variable value is not null (which it is in my case of attempting to clear the selected value of the tree).


            • 3. Re: Tree selection is always remembered?
              andrew.rw.robinson

              Determined that this is a bug/limitation with the AJAX re-rendering:

              http://jira.jboss.com/jira/browse/RF-34