B30-1852313.zul {{IS_NOTE Purpose: Description: History: Tue Dec 18 11:32:12 TST 2007, Created by jumperchen }}IS_NOTE Copyright (C) 2007 Potix Corporation. All Rights Reserved. {{IS_RIGHT }}IS_RIGHT --> xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:n="http://www.zkoss.org/2005/zk/native"> When you open the tree node, the browser should not have any error! int counter = 3; String az = "The quick brown fox jumped over the lazy dog"; Random r = new Random(); EventListener aa = new EventListener() { public void onEvent(Event event) { autoAdd( event.target ); } }; void autoAdd(Treeitem parent) { if ( parent.treechildren == null ) parent.appendChild( new Treechildren() ); if ( !parent.empty ) return; for (int i=0; i < 10; i++) { Treeitem ti = new Treeitem(); Treerow tr = new Treerow(); String c = Integer.toString( ++counter ); for ( int x=0 ; x < 4 ; x++ ) { switch ( r.nextInt() % 3 ) { case 0: createLabelCell (c).setParent(tr); break; case 1: createDoubleCell(counter).setParent(tr); case 2: createLabelCell (az).setParent(tr); break; } } tr.setParent(ti); ti.setOpen(false); ti.appendChild( new Treechildren() ); ti.addEventListener( "onOpen", aa ); ti.setParent( parent.treechildren ); } } Treecell createDoubleCell( Double x ) { Treecell tc = new Treecell(); tc.appendChild( new Doublebox( x ) ); return tc; } Treecell createLabelCell( String x ) { Treecell tc = new Treecell(); tc.appendChild( new Label( x ) ); return tc; } ]]> id="tree" rows="30" width="100%" pageSize="-1">