2 Replies Latest reply on Jul 3, 2009 12:38 AM by Steve Sobol

    Weirdness with rich:tree

    Steve Sobol Newbie

      I have an interesting situation where, under certain conditions, I can't expand a tree by clicking on it.

      The XHTML:

      <html xmlns="http://www.w3.org/1999/xhtml"
       <a4j:log popup="false" level="WARN" width="500" height="300"/>
       <a4j:form id="folderTreeForm">
       <a4j:commandButton reRender="folderTree" actionListener="#{test.populate1}" value="Pop 1"></a4j:commandButton><br/><br/>
       <a4j:commandButton reRender="folderTree" actionListener="#{test.populate2}" value="Pop 2"></a4j:commandButton><br/><br/>
       <rich:tree immediate="yes" id="folderTree" binding="#{test.tree}" value="#{test.rootNode}"
       var="item" changeExpandListener="#{test.expand}" switchType="ajax" ajaxSubmitSelection="true">

      The backing bean and a relevant snippet of my Faces config:

      package test;
      import javax.faces.event.ActionEvent;
      import org.richfaces.component.html.HtmlTree;
      import org.richfaces.event.NodeExpandedEvent;
      import org.richfaces.model.TreeNodeImpl;
      public class Test {
       private TreeNodeImpl<MyNode> rootNode = null;
       private HtmlTree tree = new HtmlTree();
       public TreeNodeImpl<MyNode> getRootNode() {
       return rootNode;
       public void setRootNode(TreeNodeImpl<MyNode> rootNode) {
       this.rootNode = rootNode;
       public HtmlTree getTree() {
       return tree;
       public void setTree(HtmlTree tree) {
       this.tree = tree;
       public void populate1(ActionEvent evt) {
       TreeNodeImpl<MyNode> first = newNode("1");
       rootNode.addChild("1", first);
       first.addChild("2", newNode("2"));
       first.addChild("3", newNode("3"));
       public void populate2(ActionEvent evt) {
       TreeNodeImpl<MyNode> first = newNode("4");
       rootNode.addChild("4", first);
       first.addChild("5", newNode("6"));
       first.addChild("6", newNode("6"));
       public TreeNodeImpl<MyNode> newNode(String s) {
       TreeNodeImpl<MyNode> temp = new TreeNodeImpl<MyNode>();
       temp.setData(new MyNode(s));
       return temp;
       public void expand(NodeExpandedEvent evt) {

      And finally, MyNode:
      package test;
      import org.richfaces.model.TreeNodeImpl;
      public class MyNode extends TreeNodeImpl<String> {
       public static final long serialVersionUID=0L;
       String value=null;
       public MyNode(String value) {
       this.value = value;
       public String getValue() {
       return value;
       public void setValue(String value) {
       this.value = value;

      If I populate the tree in response to a button click -- either using action=whatever or, in this case, using an ActionListener -- the tree will be redrawn, but if I click on the arrow to the left of the root node, nothing happens.

      In Firefox 3.0.11, running on Windows Vista Ultimate SP1, I get the warning:

      warn[13:35:44,048]: No information in response about elements to replace

      In IE 8, running on the same computer, I get an error instead:

      error[13:37:29,154]: . Error message: Invalid argument.

      If I populate the tree in my backing bean's constructor or a method annotated as @PostConstruct, the tree works properly.

      I'm new to RichFaces and I figure I may be doing something wrong.

      Thanks in advance for any help you can offer.