3 Replies Latest reply on Nov 8, 2009 6:03 AM by nbelaevski

    rich:tree help for displaying folders under a directory

      I am just learning rich:tree and have no problem in displaying a directory like a WEB-INF in a tree like structure (actually there is a very good example for this in the documentation).

      My problem is displaying folders in a tree like structure outside web app, for example displaying all files under C:\temp directory.
      Is there any reference or example regarding how to display folders and their subfolders (and their subfolders etc) from a directory (outside of WEB app)?

      I was trying to use java.io to capture directories and files and rich:recursiveTreeNodesAdaptor without any luck so far.
      Any help would be appreciated.

      Thank you,

        • 1. Re: rich:tree help for displaying folders under a directory
          nbelaevski

          Hi,

          What's the problem with doing that?

          • 2. Re: rich:tree help for displaying folders under a directory

            Hi,

            Let's say I have three folders: folder1, folder2, and folder3 in C:\temp directory. I am trying to get the three folders in xhtml using a similar rich:tree snippet like:

            <h:form>
            <rich:tree style="width:300px" switchType="ajax" stateAdvisor="#{treeDemoStateAdvisor}">
            <rich:recursiveTreeNodesAdaptor roots="#{fileSystemBean.sourceRoots}" var="item" nodes="#{item.nodes}" />
            </rich:tree>
            </h:form>

            I am able to present folder1, folder2, and folder3 in tree. (At least I can do this).
            But when I select any one of them, instead of getting the files and subdirectories of the folder, I am getting folder1,folder2, and folder3 again as subdirectories. I mean if I select folder1 in tree, I see folder1,folder2,folder3 as children elements. When I select one of the children folders, I am again getting folder1, folder2, and folder3. I think I can continue to get the same content till there is an Out Of Memory stack overflow.
            I think I have a problem in my stateAdvisor. I am using the one provided
            in one of your demos.

            public class TreeDemoStateAdvisor implements TreeStateAdvisor {
            public Boolean adviseNodeOpened(UITree tree) {
            if (!PostbackPhaseListener.isPostback()) {
            Object key = tree.getRowKey();
            TreeRowKey treeRowKey = (TreeRowKey) key;
            if (treeRowKey == null || treeRowKey.depth() <= 2) {
            return Boolean.TRUE;
            }
            }
            return null;
            }

            public Boolean adviseNodeSelected(UITree tree) {
            return null;
            }

            }

            I think the problem is I cannot get a relation between my data model and UI Tree, and I keep getting the same main folders as children folders over and over.
            Any help would be appreciated greatly.

            Thanks,

            • 3. Re: rich:tree help for displaying folders under a directory
              nbelaevski

              Hi,

              It's easy to check whether it's the thing really causing problems - just remove "stateAdvisor" attribute.