0 Replies Latest reply on Oct 2, 2007 1:49 PM by rconaway

    Replace the data behind a tree in response to other input.

    rconaway

      I am using a RichFaces HtmlTree. I'd like to replace the data behind the tree in response to a change event on a listbox. I.e. the listbox selects the customer and each customer has their own tree of data.

      I've had some success by binding the tree to a backing bean. When the listbox changes, I rebuild the TreeNode structure and assign the new structure to the value() property of the HtmlTree. This works until I expand one of the nodes in the tree. If I change the customer after that, I get this message:

      java.lang.IllegalStateException: No tree element available or row key not set!
      


      It sounds like I need to collapse the tree before I change the value, but I haven't had any success figuring out how. Besides, I may be on completely the wrong track.

      Here is part of the .xhtml:
      <h:selectOneMenu immediate='true' id='currentCustomer'
       value='#{auth.currentCustomerId}' onchange='submit()'>
       ...
      
      <rich:tree id='tree' switchType="client" style="width:300px"
       binding="#{auth.rootNode}" var="item" nodeFace="#{item.type}" >
       ...
      


      Here is relevant code from the backing bean:
      public void setCurrentCustomerId(Integer customerId) {
       currentCustomer = em.find(AuthCustomer.class, customerId);
       initRoot(); // initializes root, the data behind the tree
       rootNode.setValue(root);
      }
      


      Again, I'd like to completely change the data behind a tree in response to an input.

      Any help is greatly appreciated.

      Rob