I have rich:tree
Java Code:
<body>
<h:form>
    <rich:panel style="width:200px;">
        <f:facet name="header">The Tree</f:facet>
        <rich:tree id="tree" value="#{myTreeBean.root}"
            nodeSelectListener="#{myTreeBean.selectionListener}"
            ajaxSubmitSelection="true">
        </rich:tree>
    </rich:panel>
</h:form>
</body>
and I have

Java Code:
import org.richfaces.component.UITree;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;
public class MyTreeBean {
    private TreeNode<String> root = new TreeNodeImpl<String>();
    private static int id = 0;
    public MyTreeBean() {
        final int FIVE = 5;
        TreeNodeImpl<String> temp;
        for (; id < FIVE; id++) {
            temp = new TreeNodeImpl<String>();
            temp.setData("Node #" + id);
            root.addChild(id, temp);
        }
    }
    public void selectionListener(NodeSelectedEvent event) {
        UITree selected = (UITree) event.getComponent();
        TreeNodeImpl<String> selectedNode = (TreeNodeImpl<String>) selected
                .getModelTreeNode();
        TreeNodeImpl<String> child = new TreeNodeImpl<String>();
        child.setData("hello");
        selectedNode.addChild(id++, child);
    }
    public TreeNode<String> getRoot() {
        return root;
    }
    public void setRoot(TreeNode<String> root) {
        this.root = root;
    }
}
how can I expand any node and there's selected node :confused: