Rendering Tree Structure from nested Iterators

I am attempting to create a master-detail tree structure using nested iterators using JDeveloper 11.1.1.6.0. I have my data control set up and the master - child relation is set up using a view link.
The intent is to be able to have a form that results in the following basic design:
------------------|
parent 1 details
-child 1 details and operations
-child 2 details and operations
------------------|
parent 2 details
-child 3 details and operations
------------------|
Thus far when I've tried nested iterators using the data control, I instead get the following:
------------------|
parent 1 details
-child 1 details and operations
-child 2 details and operations
-child 3 details and operations
------------------|
parent 2 details
------------------|
-child 1 details and operations
-child 2 details and operations
-child 3 details and operations
------------------|
I've attempted to get this to work by using two completely seperate binding iterators, each tied to a different af:iterator in the following structure:
<af:iterator id="i1" value="#{bindings.parent.collectionModel} var="row" rows="#{bindings.parentIterator.rangeSize}">
  <af:panelBox text="#{row.bindings.detail.inputValue}">
    <af:iterator id="i2" value="#{bindings.child.collectionModel}" var="row2" rows="#{bindings.childIterator.rangeSize}">
      <af:outputText value="#{row2.bindings.detail.inputValue}"/>
    </af:iterator>
  </af:panelBox>
</af:iterator>However, this renders the above situation. I have not been ablue to figure out how to have the second iterator's values be dependant on the current row of the first iterator. I can get the organizational structure to work using an af:tree element and my data control. However, I cannot modify the look of the af:tree elements to match what is required by the customer, nor do I beleive that I could create the required functionality using it. Does anyone have any suggestions on how to get this to work?
Thank you
Edited by: user13468716 on May 15, 2012 6:23 AM

You can't use collectionModel for both the iterators. You will either need to create a treeBinding with a tree level rule and refer the first one as +#{bindings.<TreeBindingName>.treeModel}+ name it as row
and refer to the next iterator as #{row.<TreeLevelRuleName>}.
This will atleast create the stamping of the rows properly.Something like this -
<af:iterator id="i1" value="#{bindings.parent.treeModel} var="row" rows="#{bindings.parentIterator.rangeSize}">
  <af:panelBox text="#{row.bindings.detail.inputValue}">
    <af:iterator id="i2" value="#{row.child}" var="row2" rows="#{bindings.childIterator.rangeSize}">
      <af:outputText value="#{row2.bindings.detail.inputValue}"/>
    </af:iterator>
  </af:panelBox>
</af:iterator>where +parent+ is a treeBinding having +child+ as a tree level rule
Edited by: Sudipto Desmukh on May 15, 2012 6:57 PM

Similar Messages

  • How to populate Tree structure from BAPI while tree grows or shrinks

    Hi All
    Currently I am populating the tree structure from BAPI based on the HLevel (Hierarchy  Level) parameter, but when ever insertion and deletion happens in the tree at any level in the UI and at the same time i am updating these tree node values with HLevel value(example : 1 is first level , 2 is second level, 3 is third level etc)  updating successfully& correctly  into the BAPI, no issues.
    Once it is updated into the BAPI, next time when i refreshed the UI then i am not populating the tree structure correctly from BAPI with updated new nodes based on the HLevel. when tree struture grows or shrinks in the BAPI after updating into BAPI from UI then i am not populating the tree sturcture correctly based on the HLevel value from the BAPI.
    Please let me know any sample code how to populate tree structure correctly when tree structure grows or shrinks based on the HLevel value ( Hierarchy Level , for example : 1 is level , 2 is 2nd level , 3 is third level nodes etc)
    anybody helps in this regard with sample code on the populating tree tructure then it would be great help to me.
    Thanks in advance
    Regards
    Kalki Reddy
    Edited by: KalkiReddy on Nov 29, 2009 3:48 PM

    Bapi output node:
    Value     | Text     | HLevel
    01     | A     | 1               
    0101     | AA       | 2
    010101     | AAA     | 3
    01010B     | AAB     | 3
    0102     | AB     | 2
    02     | B     | 1
    0201     | BA        | 2
    This code is used to build the tree in wdDoInit method
         IE_T_CatalogueNode catalogueNode = wdContext.nodeE_T_Catalogue();
         int size = catalogueNode.size();
         ICatalogoElement level1elem = null;
         for (int i = 0; i < size; i ++)
              IE_T_CatalogueElement catalogueElem = catalogueNode.getE_T_CatalogueElementAt(i);
              if (catalogueElem.getLevel().equals("1"))
                   // 1 Livello
                   level1elem = wdContext.createCatalogoElement();
                   level1elem.setKATALOGART_CODE(catalogueElem.getKatalogart());
                   level1elem.setCODEGRUPPE_CODE(catalogueElem.getCodegruppe());
                   level1elem.setCODE(catalogueElem.getCode());
                   level1elem.setCODE_DESCR(catalogueElem.getKatalogart_Descr());
                   level1elem.setDESCR(catalogueElem.getKatalogart_Descr());
                   wdContext.nodeCatalogo().addElement(level1elem);
                   for (int j = i + 1; j < size; j ++)
                        IE_T_CatalogueElement catalogueElem2level =
                                                 catalogueNode.getE_T_CatalogueElementAt( j );
                        String level2 = catalogueElem2level.getLevel();
                        if (level2.equals("2"))
                             ICatalogoElement level2elem = level1elem.nodeChild().createCatalogoElement();
                             level2elem.setKATALOGART_CODE(catalogueElem2level.getKatalogart());
                             level2elem.setCODEGRUPPE_CODE(catalogueElem2level.getCodegruppe());
                             level2elem.setCODE(catalogueElem2level.getCode());
                             level2elem.setCODE_DESCR(catalogueElem2level.getCodegruppe_Descr());
                             level2elem.setDESCR(catalogueElem2level.getCodegruppe_Descr());
                             level1elem.nodeChild().addElement(level2elem);
                             for (int k = j + 1; k < size; k ++)
                                  IE_T_CatalogueElement catalogueElem3level =
                                                           catalogueNode.getE_T_CatalogueElementAt( k );
                                  String level3 = catalogueElem3level.getLevel();
                                  if (level3.equals("3"))
                                       ICatalogoElement level3elem = level2elem.nodeChild().createCatalogoElement();
                                       level3elem.setKATALOGART_CODE(catalogueElem3level.getKatalogart());
                                       level3elem.setCODEGRUPPE_CODE(catalogueElem3level.getCodegruppe());
                                       level3elem.setCODE(catalogueElem3level.getCode());
                                       level3elem.setCODE_DESCR(catalogueElem3level.getCode_Descr());
                                       level3elem.setDESCR(catalogueElem3level.getCode_Descr());
                                       level2elem.nodeChild().addElement(level3elem);
    Damiano

  • Generate Tree Structure from DB - XSQL??

    We have a table that contains a tree structure using Parent/Child fields. We use "Connect By" to extract this in normal applications to show in a tree control.
    We now want this in XML format output by our web server, where a client side app running in the browser can load this.
    I have looked at XSQL utility but it looks to only generate a simple flat structure.
    Anyone have an idea of how to automatically create a tree structure straight from the DB?
    Thanks
    Rob

    You downloaded the wrong XML Parser!
    XSQL requires Java Parser. Well, there's a copy included with the XSQL package so you actually don't need to do another download.
    You really don't need XSQL if you just want a XML file from DB, you just needed a XML SQL Utility. Download that and run the samples.

  • t:tree component is not rendering tree structure for my page

    Dear dudes,
    I want to create a simple tree structure in my jsf page backed by a backing bean.
    But my jsf page is getting executed but my tree is not getting displayed.
    my jsf page:<ui:composition xmlns="http://www.w3.org/1999/xhtml"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:s="http://jboss.com/products/seam/taglib"
         xmlns:rich="http://richfaces.ajax4jsf.org/rich"
         xmlns:t="http://myfaces.apache.org/tomahawk"
         xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
    <f:view>
         <html>
              <body>
                   <h:form>
                        <t:tree id="tree" value="#{mytreeBean.myTree}" styleClass="tree"
                             nodeClass="treenode" selectedNodeClass="treenodeSelected"
                             >
                        </t:tree>
                   </h:form>
              </body>
         </html>
    </f:view>
    </ui:composition>Mybacking bean:
    package org.test.tree;
    import java.util.Iterator;
    import java.util.List;
    import org.apache.myfaces.custom.tree.DefaultMutableTreeNode;
    import org.apache.myfaces.custom.tree.model.DefaultTreeModel;
    import com.srit.framework.web.BasePage;
    import com.srit.healthcare.common.lookupentity.repository.ILookupRepository;
    import com.srit.healthcare.common.tree.domain.RcareTree;
    public class MyTreebean {
         private DefaultTreeModel myTree;
         public DefaultTreeModel getMyTree() {
              return myTree=getTreeModel();
         public void setMyTree(DefaultTreeModel myTree) {
              this.myTree = myTree;
         /*public MyTreebean() {
              DefaultMutableTreeNode root = new DefaultMutableTreeNode("XY");
              DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
              root.insert(a);
              DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
              root.insert(b);
              DefaultMutableTreeNode c = new DefaultMutableTreeNode("C");
              root.insert(c);
              DefaultMutableTreeNode node = new DefaultMutableTreeNode("a1");
              a.insert(node);
              node = new DefaultMutableTreeNode("a2 ");
              a.insert(node);
              node = new DefaultMutableTreeNode("b ");
              b.insert(node);
              a = node;
              node = new DefaultMutableTreeNode("x1");
              a.insert(node);
              node = new DefaultMutableTreeNode("x2");
              a.insert(node);
              myTree = new DefaultTreeModel(root);
         public DefaultTreeModel getTreeModel() {
              DefaultMutableTreeNode root = new DefaultMutableTreeNode("XY");
              DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
              root.insert(a);
              DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
              root.insert(b);
              DefaultMutableTreeNode c = new DefaultMutableTreeNode("C");
              root.insert(c);
              DefaultMutableTreeNode node = new DefaultMutableTreeNode("a1");
              a.insert(node);
              node = new DefaultMutableTreeNode("a2 ");
              a.insert(node);
              node = new DefaultMutableTreeNode("b ");
              b.insert(node);
              a = node;
              node = new DefaultMutableTreeNode("x1");
              a.insert(node);
              node = new DefaultMutableTreeNode("x2");
              a.insert(node);
              return myTree = new DefaultTreeModel(root);
    }Also i've configured my tomahawk-taglib file in my web.xml .
    My backing bean is configured in my faces-config.xml
    But i'm not able to get my tree structure in my page .
    Any help would be appreciated.
    Regards

    Dear akash,
    yes i'm seeing the jsf tags <t:tree>
    But when i modify my jsf page , in my configuration files i'm getting the following errors:
    In web.xml
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">
    </web-app>
    error message:  cannot find the declaration of element web-apps
    error message: failed to read schema document http://java.sun.com/xml/ns/j2ee             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd  because 1) couldnot find the document 2) the document could not be read 3) the root element of the document is not <xsd:schema>In another configuration file:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
    Error: cannot find the declaration of element 'beans'I'm a novice to JSF technology and plz guide me properly.

  • How to Show floders and documents as a tree structure from path only

    sir,
    I am doing system side project using Java..
    so i want to know how to show folders and documents as tree structure format..
    plz give your idea regarding this?

    See for example Tree taglib in Coldtags suite:
    http://www.servletsuite.com/jsp.htm

  • Loading in tree structure from arraylist

    Hi,
    I have a ArrayList contains xml file path like
    ArrayList al={"/folder1/sub1/sub11/1.xml",
    "/folder1/sub1/2.xml,
    "/folder1/test1/3.xml",
    "/folder2/sub2/4.xml",
    "/folder2/sub2/sub3/5.xml"}
    Note: 1.This arraylist objects are dynamically loaded.
    2.The objects in array list are not file system directory path like (e.g., C:/folder1/sub1/.....). Its string added in arraylist.
    using this arraylist i want to load it in jsp tree structure, like
    folder1
    |___sub1
    | |_sub11
    | | |__1.xml
    | |_2.xml
    |___test1
    |_3.xml
    folder2
    |
    |_sub2
    |___4.xml
    |___sub3
    |___5.xml
    Can any one help me with logic or predefined function in java to iterate each string array object and split parent and sub child folder and load it in tree.
    Edited by: manjunath_2284 on Aug 11, 2009 6:04 AM

    Create a Node class that has a name and Map<String, Node> as children.
    Iterate over the list, split each entry on "/", and place the parts that you get into the Node structure.

  • How to get tree structure from file list?

    I have got following rows from my select query presenting a folder structure:
    PATH
    /KING/JONES/SCOTT
    /KING/JONES/SCOTT/ADAMS
    /KING/JONES/FORD
    /KING/JONES/FORD/SMITH
    /KING/BLAKE
    /KING/BLAKE/ALLEN
    /KING/BLAKE/WARD
    /KING/BLAKE/MARTIN
    /KING/BLAKE/TURNER
    /KING/BLAKE/JAMES
    /KING/CLARK
    /KING/CLARK/MILLER
    /PALO/TEMP
    On base of this data I need to build tree in my application by effecient way.
    Therefore i would like to achieve data (SELECT with two columns) as bellow:
    FOLDER        PARENTFOLDER
    KING     NULL
    JONES   KING
    SCOTT  KING/JONES
    ADAMS  KING/JONES/SCOTT
    FORD     KING/JONES
    SMITH    KING/JONES/FORD
    BLAKE    KING
    ALLEN    KING/BLAKE
    WARD    KING/BLAKE
    MARTIN  KING/BLAKE
    TURNER  KING/BLAKE
    JAMES    KING/BLAKE
    CLARK     KING
    MILLER    KING/CLARK
    PALO      NULL
    TEMP      PALOIs this possible to do it on SQL level(not PL SQL)?
    Thanks

    Perhaps something like this?
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '/KING/JONES/SCOTT' as path from dual union all
      2             select '/KING/JONES/SCOTT/ADAMS' from dual union all
      3             select '/KING/JONES/FORD' from dual union all
      4             select '/KING/JONES/FORD/SMITH' from dual union all
      5             select '/KING/BLAKE' from dual union all
      6             select '/KING/BLAKE/ALLEN' from dual union all
      7             select '/KING/BLAKE/WARD' from dual union all
      8             select '/KING/BLAKE/MARTIN' from dual union all
      9             select '/KING/BLAKE/TURNER' from dual union all
    10             select '/KING/BLAKE/JAMES' from dual union all
    11             select '/KING/CLARK' from dual union all
    12             select '/KING/CLARK/MILLER' from dual union all
    13             select '/PALO/TEMP' from dual
    14            )
    15  --
    16  -- END OF TEST DATA
    17  --
    18  select distinct substr(path,instr(path,'/',1,rn)+1,decode(instr(path,'/',1,rn+1),0,length(path)+1,instr(path,'/',1,rn+1))-instr(path,'/',1,rn)-1) as folder, substr(path,2,instr(path,'/',1,rn)-2) as parent
    19  from t
    20       cross join (select rownum rn from dual connect by rownum <= (select max(length(regexp_replace(path,'[^/]'))) from t)) x
    21* where instr(path,'/',1,rn) > 0
    SQL> /
    FOLDER                  PARENT
    BLAKE                   KING
    SCOTT                   KING/JONES
    JAMES                   KING/BLAKE
    MARTIN                  KING/BLAKE
    SMITH                   KING/JONES/FORD
    KING
    WARD                    KING/BLAKE
    ADAMS                   KING/JONES/SCOTT
    FORD                    KING/JONES
    TURNER                  KING/BLAKE
    MILLER                  KING/CLARK
    PALO
    TEMP                    PALO
    JONES                   KING
    CLARK                   KING
    ALLEN                   KING/BLAKE
    16 rows selected.
    SQL>

  • Tree movement from Peoplesoft to Hyperion

    Hi all,
    I'm new to DRM and presently working on implementing a project where DRM would be used to manage the Hierarchies and Peoplesoft would be the main application which would send tree structures to DRM on an adhoc basis. My Question is,
    1. What are are ways to move tree structures from P.S into DRM ?
    One thing is to take exports from P.S ,then manipulate it to a DRM readable format and then import it into DRM (and then Blend with the existing tree). But what are the other options available here?
    2. Also, how to set up Hyperion DRM initially with the P.S tree structures?
    Regards,
    Suvi

    Have you seen this one: http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/hyperion_hps.chm
    Cheers,
    Mehmet

  • How do I read text from specific rows and columns in a tree structure?

    How do I read text from specific rows and columns in a tree structure? In a table you can specify the cell to read from but I have not been able to figure out how to do this with a tree structure.

    You need to set two properties to activate the correct cell and then you can read it's string property.
    The positioning properties are the "ActiveItemTag" and
    "ActiveColNum" properties. With them you select the tree item by it's tag and the active column. The string can then be read from the "Cell String" property.
    MTO

  • Create a Tree Node Structure from XML

    Hi
    We have a requirement where we have an XML file we want to create the Tree Node structure from the XML can anyone help out on this
    We are referring to the following blog but in that it is coming from KM content and we require the tree structure to form from a XML file
    http://wiki.sdn.sap.com/wiki/display/Snippets/SmartNavigationTreeforKM+Folders
    Can anyone help me
    Regards
    JM

    Hi,
    Could you elaborate a litle more exacly what you need to do?
    I found the link http://help.sap.com/saphelp_470/helpdata/en/86/8280db12d511d5991b00508b6b8b11/content.htm that maybe assist you.
    Please remember to evaluate the replays, this incentive the SDN to keep growing,
    regards,
    Fabio

  • How do you retrieve child tags from a parent tag in a tree structure and build an array from it?

    Is there a property node somewhere that can retrieve the tags of all the children of an "active" parent tag in a tree structure? If I click on the parent tag, I want to be able to show what child tags are under that parent tag.

    There is not a property or method that I have been able to find, however I wrote this VI that given a parent tag returns all the children.
    Evan Collier
    Attachments:
    Get_1_Lv_of_children.vi ‏59 KB

  • How to get Tree structure in JSP page?

    Hi,
    I would like get data from the database and display the data in tree structure with the check boxes at each nodes on a jsp page with out using any third party tools. how can i do that? Do i require any new tags to fulfill this requirement?
    can any one help me out by sending any example code?
    thanks in advance.
    Regards,
    Reddy

    Once you have the data in a list or something, can't you just use <c:forEach> and then output standard nested <ul> and <li> tags to give the tree structure.
    <html>
         <style>
              li
                   list-style-type:none;
         </style>
         <body>
              <form>
                   <ul>
                        <li>
                             <input type="checkbox">Check 1</input>
                             <ul>
                                  <li>
                                       <input type="checkbox">Check 1A</input>
                                  </li>
                                  <li>
                                       <input type="checkbox">Check 1B</input>
                                  </li>
                             </ul>
                        </li>
                        <li>
                             <input type="checkbox">Check 2</input>
                             <ul>
                                  <li>
                                       <input type="checkbox">Check 2A</input>
                                  </li>
                             </ul>
                        </li>
                        <li>
                             <input type="checkbox">Check 3</input>
                        </li>
                   </ul>
              </form>
         </body>
    </html>

  • Listing File Hierarchy in console using a Tree structure

    first off i'm a college student. i'm not that good at java... we got this CA in class and try as i might i just can't get my head around it
    i was wondering if someone who know a bit more about java then i do would point me in the right direction, were i'm going wrong in my code
    i have to list out sub-files and sub-directorys of a folder (i.e. C:/test) to console using tree structure
    like this
    startingdir
    dir1 //subfolder of startingdir
    dir11 //subfolder of dir1
    dir111 //subfolder of dir11
    dir12 //subfolder of dir1
    file1A // document on dir1
    dir2 //subfolder of startingdir
    Tree.java
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.ListIterator;
    import java.util.NoSuchElementException;
    import java.util.Deque;
    public class Tree<E> {
        // Each Tree object is an unordered tree whose
        // elements are arbitrary objects of type E.
        // This tree is represented by a reference to its root node (root), which
        // is null if the tree is empty. Each tree node contains a link to its
        // parent and a LinkedList of child nodes
        private Node root;
        //////////// Constructor ////////////
        public Tree () {
        // Construct a tree, initially empty.
            root = null;
        //////////// Accessors ////////////
        public boolean isEmpty () {
        // Return true is and only if this tree is empty.
             return (root == null);
        public Node root () {
        // Return the root node of this tree, or null if this tree is empty.
            return root;
        public Node parent (Node node) {
        // Return the parent of node in this tree, or null if node is the root node.
            return node.parent;
        public void makeRoot (E elem) {
        // Make this tree consist of just a root node containing element elem.
            root = new Node(elem);
        public Node addChild (Node node, E elem) {
        // Add a new node containing element elem as a child of node in this
        // tree. The new node has no children of its own. Return the node
        // just added.
            Node newChild = new Node(elem);
            newChild.parent = node;
            node.children.addLast(newChild);
            return newChild;
        public E element (Node node) {
             return node.getElement();
        //////////// Iterators ////////////
        public Iterator childrenIterator (Node node) {
            return node.children.iterator();
        public Iterator nodesPreOrder () {
        // Return an iterator that visits all nodes of this tree, with a pre-order
        // traversal.
            return new Tree.PreOrderIterator();
        //////////// Inner classes ////////////
        public class Node {
            // Each Tree.Node object is a  node of an
            // unordered tree, and contains a single element.
            // This tree node consists of an element (element),
            // a link to its parent
            // and a LinkedList of its children
            private E element;
            private Node parent;
            private LinkedList<Node> children;
            private Node (E elem) {
                // Construct a tree node, containing element elem, that has no
                // children and no parent.
                this.element = elem;
                this.parent = null;
                children = new LinkedList<Node>();
            public E getElement () {
            // Return the element contained in this node.
                return this.element;
            public String toString () {
            // Convert this tree node and all its children to a string.
                String children = "";
                // write code here to add all children
                return element.toString() + children;
            public void setElement (E elem) {
            // Change the element contained in this node to be elem.
                this.element = elem;
        public class PreOrderIterator implements Iterator {
            private Deque<Node> track; //Java recommends using Deque rather
            // than Stack. This is used to store sequence of nomempty subtrees still
            //to be visited
            private PreOrderIterator () {
                track = new LinkedList();
                if (root != null)
                    track.addFirst(root);
            public boolean hasNext () {
                return (! track.isEmpty());
            public E next () {
                Node place = track.removeFirst();
                //stack the children in reverse order
                if (!place.children.isEmpty()) {
                    int size = place.children.size(); //number of children
                    ListIterator<Node> lIter =
                            place.children.listIterator(size); //start iterator at last child
                    while (lIter.hasPrevious()) {
                        Node element = lIter.previous();
                        track.addFirst(element);
                return place.element;
            public void remove () {
                throw new UnsupportedOperationException();
        FileHierarchy.java
    import java.io.File;
    import java.util.Iterator;
    public class FileHierarchy {
        // Each FileHierarchy object describes a hierarchical collection of
        // documents and folders, in which a folder may contain any number of
        // documents and other folders. Within a given folder, all documents and
        // folders have different names.
        // This file hierarchy is represented by a tree, fileTree, whose elements
        // are Descriptor objects.
        private Tree fileTree;
        //////////// Constructor ////////////
        public FileHierarchy (String startingDir, int level) {
            // Construct a file hierarchy with level levels, starting at
            // startingDir
            // Can initially ignore level and construct as many levels as exist
            fileTree = new Tree();
            Descriptor descr = new Descriptor(startingDir, true);
            fileTree.makeRoot(descr);
            int currentLevel = 0;
            int maxLevel = level;
            addSubDirs(fileTree.root(), currentLevel, maxLevel);
        //////////// File hierarchy operations ////////////
        private void addSubDirs(Tree.Node currentNode, int currentLevel,
                int maxLevel) {
        // get name of directory in currentNode
        // then find its subdirectories (can add files later)
        // for each subdirectory:
        //    add it to children of currentNode - call addChild method of Tree
        //    call this method recursively on each child node representing a subdir
        // can initially ignore currentLevel and maxLevel   
            Descriptor descr = (Descriptor) currentNode.getElement();
            File f = new File(descr.name);
            File[] list = f.listFiles();
            for (int i = 0; i < list.length; ++i) {
                if (list.isDirectory()) {
    File[] listx = null;
    fileTree.addChild(currentNode, i);
    if (list[i].list().length != 0) {
    listx = list[1].listFiles();
    addSubDirs(currentNode,i,1);
    } else if (list[i].isFile()) {
    fileTree.addChild(currentNode, i);
    // The following code is sample code to illustrate how File class is
    // used to get a list of subdirectories from a starting directory
    // list now contains subdirs and files
    // contained in dir descr.name
    ////////// Inner class for document/folder descriptors. //////////
    private static class Descriptor {
    // Each Descriptor object describes a document or folder.
    private String name;
    private boolean isFolder;
    private Descriptor (String name, boolean isFolder) {
    this.name = name;
    this.isFolder = isFolder;
    FileHierarchyTest.javapublic class FileHierarchyTest {
    private static Tree fileTree;
    public static void main(String[] args) {
    FileHierarchy test = new FileHierarchy ("//test", 1);
    System.out.println(test.toString());

    Denis,
    Do you have [red hair|http://www.dennisthemenace.com/]? ;-)
    My advise with the tree structure is pretty short and sweet... make each node remember
    1. it's parent
    2. it's children
    That's how the file system (inode) actually works.
    <quote>
    The exact reasoning for designating these as "i" nodes is unsure. When asked, Unix pioneer Dennis Ritchie replied:[citation needed]
    In truth, I don't know either. It was just a term that we started to use. "Index" is my best guess, because of the
    slightly unusual file system structure that stored the access information of files as a flat array on the disk, with all
    the hierarchical directory information living aside from this. Thus the i-number is an index in this array, the
    i-node is the selected element of the array. (The "i-" notation was used in the 1st edition manual; its hyphen
    became gradually dropped).</quote>

  • How to Implement Dynamic Tree structure in jsp

    Hi,
    Does any body help me to solve out my requirement??
    I want to display all my folder contents (parent & childs) in windows explorer format, the root folder path will come from database.
    Thanks in advance

    There are many ways to achieve this. The simplest would be to use some existing tag library that renders a tree structure and feed it with the required data.

  • Tree Structure generation in content management

    Hi,
    I am new to Oracle portals.I have a task of generating a default
    tree structure based on say somes values from database eg: DEALS1,DEALS2, DEALS3 displayed, when I create or click any of these it should open a dynamic folder structure depending on users security level.One of the examples oracle uses is when you create a content area, by default portal generates Folders
    folder , Category folder, Navigation bar folders , etc.
    2. Is it possible to achieve tree similar to the one Oracle Portal displays when we open a default content page and click Content Area Map on top left , i.e with folders expands and closes on each click to Icon.
    Thanks
    Morozov

    Is it feasible in your scenario to simply set the unwanted folders to "hidden" or is it completely ACL-based? With the regular end-user explorers (e.g. ConsumerExplorer), hidden folders won't be shown (this is a setting of the corresponding collection renderer). Administrative Explorers (e.g. Admin Explorer) do show hidden files, though. Note that you can only modify the hidden state with such an administrative explorer. This makes sure that you have at least one way to reset that state and to not hide it in an explorer that afterwards does not show the file and thus would not allow you to reverse that step (in principle this means that users with no administrative accesses whatsoever will never be able to hide resources).
    Regards, /-/ans-Juergen

Maybe you are looking for

  • Excel Graph Legend Formatting - Report Generation Tool

    Hi all, I'm currently using the Report Generation Tool for Labview '11 and cannot seem to figure out how to edit the font properties for a graph's legend. Attached is a screenshot of an example output. The Excel Graph Font.vi's Help file says that it

  • Javascript Functions in WAD

    Hi all, Could anyone tell me about all the javascript functions we can use in WAD? For exp: "<i>getElementById</i>" Thanks in advance,

  • Macbook screen fades to white and locks-up

    my macbook has a new bad habit of being slow, too many pinwheel timeouts and now the screen fades to white and must be rebooted to work for 5-10 minutes.  My research so far indicates a bad wiring between the screen and  base or overheating.  Help pl

  • VLANs and Trunking

    Okay, I know this is not strictly a Cisco question as the switches in question are HP ProCurve 2524's, but hopefully I'll be granted a pardon for that. I'm trying to create a network with two VLANs who don't speak to each other but can each access th

  • Where we will see the out put of propotional factor

    Hi Experts, I have maintained in mc8v (Proportional factor)  after this where is the out put will see for  propotional factor . I have  maintained  in basic proportion is cube ,keyfigure,verion and calculate proportion maintained planning area, keyfi