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!
<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}" > ...
public void setCurrentCustomerId(Integer customerId) { currentCustomer = em.find(AuthCustomer.class, customerId); initRoot(); // initializes root, the data behind the tree rootNode.setValue(root); }