protected void paintItem ( final WTree tree , final WTree . ExpandMode mode , final TreeItemModel model , final List < Integer > rowIndex , final XmlStringBuilder xml , final Set < String > selectedRows , final Set < String > expandedRows ) { String itemId = model . getItemId ( rowIndex ) ; boolean selected = selectedRows . remove ( itemId ) ; boolean expandable = model . isExpandable ( rowIndex ) && model . hasChildren ( rowIndex ) ; boolean expanded = expandedRows . remove ( itemId ) ; TreeItemImage image = model . getItemImage ( rowIndex ) ; String url = null ; if ( image != null ) { url = tree . getItemImageUrl ( image , itemId ) ; } xml . appendTagOpen ( "ui:treeitem" ) ; xml . appendAttribute ( "id" , tree . getItemIdPrefix ( ) + itemId ) ; xml . appendAttribute ( "label" , model . getItemLabel ( rowIndex ) ) ; xml . appendOptionalUrlAttribute ( "imageUrl" , url ) ; xml . appendOptionalAttribute ( "selected" , selected , "true" ) ; xml . appendOptionalAttribute ( "expandable" , expandable , "true" ) ; xml . appendOptionalAttribute ( "open" , expandable && expanded , "true" ) ; xml . appendClose ( ) ; if ( expandable && ( mode == WTree . ExpandMode . CLIENT || expanded ) ) { // Get actual child count int children = model . getChildCount ( rowIndex ) ; if ( children > 0 ) { for ( int i = 0 ; i < children ; i ++ ) { // Add next level List < Integer > nextRow = new ArrayList <> ( rowIndex ) ; nextRow . add ( i ) ; paintItem ( tree , mode , model , nextRow , xml , selectedRows , expandedRows ) ; } } } xml . appendEndTag ( "ui:treeitem" ) ; }
Iterate of over the rows to render the tree items .