My setup is
Richfaces 3.1.4 GA, Firefox,local deployment. My tree has 1000 nodes in 3 levels 10x10x10. It takes about 1 to 3 minutes to load if switchType is client. It seems ok if switchType is ajax. However, I'd like to use client switchType to reduce client-server traffic.
Here is my xhtml code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:c="http://java.sun.com/jstl/core"> <head> <title>test JSF</title> </head> <body> <h:form> <rich:tree switchType="client" ajaxSingle="true" ajaxSubmitSelection="true" immediate="true" preserveModel="request" reRender="programpanel" > <rich:recursiveTreeNodesAdaptor roots="#{root.roots}" var="item" nodes="#{item.nodes}" > <rich:treeNode> <span>#{item.label} <rich:toolTip value="#{item.label}"/> </span> </rich:treeNode> </rich:recursiveTreeNodesAdaptor> </rich:tree> </h:form> <ui:debug hotkey="d" /> </body> </html>
public class Root { public Node[] getRoots() { Node node = new Node(0, "0"); Node[] nodes = node.getNodes(); return nodes; } }
public class Node { protected int level; protected String label; public Node(int level, String label) { this.level=level; this.label=label; } public String getLabel() { return label; } public Node[] getNodes() { if (level<3) { Node[] nodes= new Node[10]; for (int i=0; i<10; i++) { nodes=new Node(level+1, String.valueOf(i)); } return nodes; }else { //no child return new Node[0]; } } public String toString() { return level+"."+label; } public int getLevel() { return level; } public void setLevel(int level) { this.level = level; } }