1 Reply Latest reply on Jul 4, 2007 5:57 AM by paata lominadze

    Richfaces Tree and Dinamic Gereration

    paata lominadze Master

      hi all,
      i tried to generate tree component dynamically i use richfaces tree example and add this to my program:

      Library library = new Library();
       HtmlTree tree = new HtmlTree();
       tree.setStyle("width:150px");
       tree.setValue(library.getData());
       tree.setVar("item");
       tree.setNodeFace(library.getType());
      
       Iterator<Artist> itArtists = library.getArtists().values().iterator();
       while (itArtists.hasNext()) {
       Artist artist = (Artist)itArtists.next();
      
       HtmlTreeNode artistNode = new HtmlTreeNode();
       artistNode.setType("artist");
       HtmlOutputText artistText = new HtmlOutputText();
       artistText.setValue(artist.getName());
      
       Iterator<Album> itAlbums = artist.getAlbums();
       while (itAlbums.hasNext()) {
       Album album = (Album) itAlbums.next();
      
       HtmlTreeNode albumNode = new HtmlTreeNode();
       albumNode.setType("album");
       HtmlOutputText albumText = new HtmlOutputText();
       albumText.setValue(album.getTitle());
       Iterator<Song> itSongs = album.getSongs();
       while (itSongs.hasNext()) {
       Song song = (Song) itSongs.next();
      
       HtmlTreeNode songNode = new HtmlTreeNode();
       songNode.setType("song");
       HtmlOutputText songText = new HtmlOutputText();
       songText.setValue(song.getTitle());
       tree.getChildren().add(songNode);
       }
       tree.getChildren().add(albumNode);
       tree.getChildren().add(artistNode);
       item.getChildren().add(tree);
       bar.getChildren().add(item);