0 Replies Latest reply on Feb 19, 2008 9:54 AM by Tim Grant

    rich:tree value attribute does not work

    Tim Grant Newbie

      I am using the value attribute of a rich:tree control to hold the tree's selection across page transitions. Consider this template code:

      <h:form id="myIndex">
       action="#{mySearchController.showFiles( item )}"
       value="#{item.name}" />

      And this controller code:
      @Name( "myMenuController" )
      @Scope( ScopeType.SESSION )
      public class MyMenuController implements Serializable {
       private final DocumentIndexModel model;
       private TreeNode currentSelection;
       private final List<FileSystemNode> sourceRoots;
       private Log logger;
       public MyMenuController() {
       model = new DocumentIndexModel();
       sourceRoots = model.getSourceRoots();
       public TreeNode getCurrentSelection() {
       logger.debug( "getCurrentSelection() = " + currentSelection );
       return currentSelection;
       public void setCurrentSelection( TreeNode currentSelection ) {
       logger.debug( "setCurrentSelection( " + currentSelection + " )" );
       this.currentSelection = currentSelection;
       public List<FileSystemNode> getSourceRoots() {
       return sourceRoots;

      @Name( "mySearchController" )
      @Scope( ScopeType.SESSION )
      public class BusdocsSearchController {
       private Log logger;
       @Out( required = false )
       private List<FileSystemNode> searchResults;
       @Out( required = false )
       private String shortPath;
       public String showFiles( FileSystemNode node ) {
       logger.debug( "showFiles( " + node.getPath() + " )" );
       shortPath = node.getKey();
       searchResults = node.getFiles();
       return "showFiles";
       public String getShortPath() {
       return shortPath;
       public List<FileSystemNode> getSearchResults() {
       return searchResults;

      finally, pages.xml:
      <page view-id="/view/main.xhtml">
       <rule if-outcome="showFiles">
       <redirect view-id="/view/folder_view.xhtml" />

      Both main.xhtml and folder_view.xhtml use the same tree control.

      I can see in the log where getCurrentSelection() is called, returning a null value; however, setCurrentSelection() is never called. The problem is that when I select a node, control is passed to the folder_view page and my tree selection is lost.

      This method is working well for a rich:panelBar in the same template code. Everything else about the application works well, I only cannot keep the tree selection intact.

      Any suggestions as to how I can keep the tree selection?