Af:tree expand/collapse issue

I use af:tree inside af:dialog. When the dialog is displayed I want the tree to be displayed just with root node. Child nodes should be displayed only when the root node is expanded. I have set "expandAllEnabled" property to "false" and "initiallyExpanded" to "false".
When the dialog pops up for the first time, everything works fine. meaning only the root node is displayed and only when it is expanded child nodes are displayed.
But when I close the dialog and bring it up again, I see that the root node is already expanded. I do not want root node to be expanded when the tree is loaded.
Any idea if I need to set anything explicitly for this? I tried clearing the child elements of the tree component(treeComp.getChildren().clear();), but no use. I construct the treeModel every time the dialog comes up.
Appreciate your help.
Thanks
Suma

Hi
First of all see if your af:dialog has the contentDelivery="lazyUncached" . This way your popup would not be cached.
If this is not the solution , then try:
tree.getDisclosedRowKeys().removeAll();This will remove all disclosed rowKeys.
A.Gruev

Similar Messages

  • Af:tree expand/collapse customization

    hi all,
    i have problem with af:tree expand and collapse.
    I want to expand only one node in each level.
    i mean let say i have 3 node in same level.
    i expand first one then i expand second node again. at that time, first one should be collapsed automatically.
    So, user can expand only one node in each level at one time.
    is it possible?
    With Regards,
    WP

    hi Sireesha,
    it is really helpful. but it is still something wrong for child node.
    only root node is working as i want.
    but when i click on child node, it go back to default and every node is collapse.
    if i found the following logic is not working for child node.
    discloseRowKeySet.add(firstKey);
    eg. let say fristkey is (2,0) then it should open 2 and then second level 0. but it can't open any node.
    do u have any idea?
    With Regards,
    WP

  • Af|tree::expanded-icon issue ?

    af|tree::expanded-icon
    content: url(/skins/mycompany/skin_images/expand.gif);
    width:16px;
    height:16px;
    i recieve error at af|tree::expanded-icon line (on second COLON':').Css file does not accept this identifier there ? i have tried many ways but all in vain.
    is there any thing special i need to import for new af|tree styles? I am using JDev 10.1.3.3

    Hi
    First of all see if your af:dialog has the contentDelivery="lazyUncached" . This way your popup would not be cached.
    If this is not the solution , then try:
    tree.getDisclosedRowKeys().removeAll();This will remove all disclosed rowKeys.
    A.Gruev

  • Issue With ADF Tree Expand/Collapse

    Hi All,
    I have a customer who is having issues using the af:tree component on a deployed application. When he tries to expand or collapse a node of the tree, the icon just blinks. This is occurring not only on our application, but also the Oracle ADF Rich Client Demo on http://jdevadf.oracle.com/adf-richclient-demo/faces/components/tree.jspx. He is using Internet Explorer v7.0.5730.13. As far as I can tell, our browser settings are identical, but I can use the tree without a problem.
    Any ideas as to what the problem could be?
    Thanks,
    Brad

    Unfortunately, Internet Explorer is the only browser that is authorized to run on his computer.
    Do you know of any specific IE settings that would cause the af:tree not to work?

  • DHTML Tree Expand-Collapse ALL buttons

    Hi
    I am using at DHTML Tree (in APEX 3.0.1) as a menu. I am wondering if it is possible to add buttons (or link) to the region which a user can click to expand all or collapse all nodes in the tree.
    I don not want the tree to be expanded or collapsed all the time (as when using the Tree List template)
    Thanks

    Anyone?

  • ADF Faces af:tree expand/collapse node

    Any help appreciated. Is there a way to specify in the tree model if you want a node expanded or collapsed? I am using the ChildPropertyTreeModel and TreeNodeImpl as the nodes. Can I add an additional property to the Tree Node?
    Thanks

    There isn't anything in the framework that lets you specify tree expansion state in the model. The frameword tries to preserve the abstraction between the model (which should only contain data) and the UI component (which handles expansion state).
    You can build a custom renderer for the tree where you can remember which paths from your model are expanded, and then set the expansion state of the tree programmatically by calling the UIXTree.setTreeState() method. It takes a set of paths, with each path corresponding to a path you want to be expanded.

  • When using numericupdown to expand/collapse treeView nodes. Why the collapse part is not working ?

    I have a treeView in my form1 designer. The treeView variable name is: treeViewMS1
    When i'm running my program the treeView is automatic expanded to level 1:
    Now if i click on the numericUpDown and change the value to 2 then:
    So the expanded part is working fine when i change of the numericUpDown by one up the expanded is working fine.
    Now when it's on level 2 and i change the numericUpDown back to value 1 that's level 1 instead get back to my first screenshot Expanded level 1 it's getting back to the root level 0.
    and i want that the collapse part will move only one level back but it dosen't matter if i'm on expanded level 2 or 3 or 5 it will allways jump to 0 to the root.
    This is the numericUpDown value changed event:
    decimal oldValue;
    private void numericUpDown1_ValueChanged(object sender, EventArgs e)
    if (numericUpDown1.Value > oldValue)
    ExpandToLevel(treeViewMS1.Nodes, (int)numericUpDown1.Value);
    else
    CollapseToLevel(treeViewMS1.Nodes, (int)numericUpDown1.Value);
    oldValue = numericUpDown1.Value;
    ExpandToLevel method:
    void ExpandToLevel(TreeNodeCollection nodes, int level)
    if (level > 0)
    foreach (TreeNode node in nodes)
    node.Expand();
    ExpandToLevel(node.Nodes, level -1);
    And CollapseToLevel method:
    void CollapseToLevel(TreeNodeCollection nodes, int level)
    if (level > 0)
    foreach (TreeNode node in nodes)
    node.Collapse();
    CollapseToLevel(node.Nodes, level - 1);

    I solved it this way:
    I solved it like this: In the Form1_Load event i did:
    SetToLevel(treeViewMS1.Nodes, 1);
    In my case i wanted it to begin by default in level 1.
    Then in the numericupdown1 changed value event:
    private void numericUpDown1_ValueChanged(object sender, EventArgs e)
    SetToLevel(treeViewMS1.Nodes, (int)numericUpDown1.Value);
    Then the method SetToLevel:
    void SetToLevel(TreeNodeCollection nodes, int level)
    foreach (TreeNode node in nodes)
    node.Collapse(false);
    ExpandToLevel(nodes, level);
    And last the method EXpandToLevel:
    void ExpandToLevel(TreeNodeCollection nodes, int level)
    if (level > 0)
    foreach (TreeNode node in nodes)
    node.Expand();
    ExpandToLevel(node.Nodes, level -1);
    And now it's working perfect like i wanted it to work. When changing the numericupdown value it's changing the node tree expand/collapse levels.

  • Decision Report: Toggling Expand / Collapse All (v10.2)

    Hi everyone,
    We're wondering if anyone can share an approach for enabling users to "expand/collapse all" (all nodes) in a decision report dynamically - i.e. using a button or toggle, rather than a global configuration or preference setting. For example, we would like to initially display a collapsed report (to show the high-level conclusions), and then enable the client to fully expand the report for printing.
    Importantly, we would like to be able to do this in version *10.2*.
    Thanks,
    - Patrick

    Granting my JavaScript is a bit rusty, I'm wondering if anyone else has encountered the following challenge when changing the global configuration settings for decision report (expanded/collapsed):
    Issue: The plus signs ( + ) at the nodes appear as minus signs ( - ), and vice versa. In other words, after our modifications, the user needs to click on a minus sign to expand a node.
    Our approach was simply to do a CTRL-F and replace "expanded" with "collapsed", so it's not surprising that there were unintended side effects.

  • Trying to override the default af:tree expanded and collapsed icons

    Hi,
    I initially hijacked a thread from 2010 that was vaguely similar to what I need to ask, but a kind forum moderator split my post out to stand on its own merits.
    I am trying to override the default af:tree expanded and collapsed icons I am using the following styles for my af:tree but they are not reflecting any thing on my tree with the styleclass orgType.
    af|tree.orgType::expanded-icon {
    content: url("../images/ac-expand.png");
    cursor: default;
    af|tree.orgType::collapsed-icon {
    content: url("../images/ac-collapsed.png");
    cursor: default;
    af|tree::expanded-icon {
    content: url("../images/folder_open.png");
    cursor: default;
    af|tree::collapsed-icon {
    content: url("../images/folder_close.png");
    cursor: default;
    After working for long hours I realized that there is some problem with af:tree and treeTable. They are not taking the styles where as for the other components, every thing works fine. Is there any way to achieve the task. Could you suggest any alternative way to do this. Thanks in advance. Your suggestions for this task can really help me and my team a lot.
    Regards,
    Krishna Sumanth.

    Hi,
    do the icons show without the style class reference used in the skin file? If so, then the style class for this component might be rendered differently for the tree, e.g.
    .orgType af|tree ...
    Frank

  • Dynamic tree structure (expand/collapse)

    i want to do one tree struc example (expand /collapse)
    using xml;
    like
    WOrld
    |
    |
    ----INDIA
    |
         -------Andhrapradesh
    |
              |
    -----------------Hyderabad
              |               |                         |           Visakhapatnam
              Karnataka
    |
              |                    
    Tamilnadu
    America
    |
    Australia
    in the frame at left side tree structure will be there ;when i click world hyperlink and at the right side one forum will come like this;
    country name ---------
    description ---------
    when i enter america and enter submit;the country should come in the left frame;i will refresh left frame when click submit;ofcourse i know that;like wise when i click state hyperlink
    state name ---------
    description ---------
    statename should come under state tree node;
    i will also maintain this info in database also;i am using oracle9i;how can i do this the tree structure;how to approach;if anybody give me any links revelant to this?atleast give me some idea what to do?please dont give me the DOM tutorial or SAX Tutorial cos i already gone through but i didnt get any idea.
    bye
    chaitanya

    Initailly set xerces.jar (parser, freeware download from apache site) to calss path
    Suppose
    <WORLD>
    <INDIA>
    <ANDHRA>abc</ANDHRA>
    <VISHAKHA>fsdfd</VISHAKHA>
    <UP>dss</UP>
    </INDIA>
    <USA>
    <FLORIADA>bsbs</FLORIADA>
    <NEWYORK>dsds</NEWYORK>
    </USA>
    </WORLD>
    try{
    dbf = DocumentBuilderFactory.newInstance();
    db = dbf.newDocumentBuilder();
    mapDocument = db.newDocument();
    Element worldElement = mapDocument.createElement("WORLD");
    Element indiaElement = mapDocument.createElement("INDIA");
    Element andhraElement = mapDocument.createElement("ANDHRA");
    andhraElement.appendChild(mapDocument.createTextNode("sdsd");
    Element vishakhaElement = mapDocument.createElement("VISHKHA");
    vishkhaElement.appendChild(mapDocument.createTextNode("sdfdf");
    Element upElement = mapDocument.createElement("UP");
    upElement.appendChild(mapDocument.createTextNode("fsfs");     
    indiaElement.appendChild(andhraElement)
         .appendChild(vishkhaElement)
         .appendChild(upYElement)
    //lly do for usaELement
    //finally add indiaElemebnt and usaElement to worldElement                    
    worldElement.appendChild(indiaElement)
         .appendChild(usaElement)
    mapDocument.appendChild(worldElement);          
    }catch(FactoryConfigurationError fce){
         fce.printStackTrace();
    }catch(ParserConfigurationException pce){
    pce.printStackTrace();
    I think this u need

  • Macking button to expand the tree and collapse tree and another to add node

    macking button to expand the tree and collapse tree and another to add node and saving the changes in the database ( this is problem)
    and finally delete node from database
    so what is proper code for those buttons
    thanks my mail is :
    [email protected]

    Hello,
    Use the ftree package's functions
    code to expand all nodes:
    PROCEDURE explose_tree IS
    node    ftree.node;
    htree   ITEM;
    state   varchar2(30);
    BEGIN
       -- search the tree ID --
       htree := Find_Item('BL_TREE.TREE_1');
        -- search the root --
           node  := Ftree.Find_Tree_Node(htree, '');
        -- expand all nodes --
       WHILE NOT Ftree.ID_NULL(node) LOOP
          state := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_STATE);
          IF state = Ftree.COLLAPSED_NODE THEN
            Ftree.Set_Tree_Node_Property(htree, node, Ftree.NODE_STATE, Ftree.EXPANDED_NODE);
          END IF;
          node := Ftree.Find_Tree_Node(htree, '', ftree.find_NEXT,Ftree.NODE_LABEL,'', node);
       END LOOP;
    END;and to collapse all nodes:
    PROCEDURE Implose_tree IS
       node   ftree.node;
       htree  ITEM;
       state  varchar2(30);
    BEGIN
       -- search the root ID --
       htree := Find_Item('BL_TREE.TREE_1'); 
       -- search the root --
       node  := Ftree.Find_Tree_Node(htree, '');  
       -- Collapse all nodes --
       WHILE NOT ftree.ID_NULL(node) LOOP
         state := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_STATE);
         IF state = Ftree.EXPANDED_NODE THEN
          Ftree.Set_Tree_Node_Property(htree, node, Ftree.NODE_STATE, Ftree.COLLAPSED_NODE);
         END IF;
        node := Ftree.Find_Tree_Node(htree, '', Ftree.FIND_NEXT,Ftree.NODE_LABEL, '', node);
       END LOOP;
    END; Francois

  • TP4 FileExplorer tree: change Folder icon when expanded/collapsed

    I am trying to create a tree similar with FileExplorer from the Demo application. I am trying to use two icons for every node: one for expanded node and another one for collapsed.
    I use a rowDisclosureListener tag
    rowDisclosureListener="#{menuBean.menuRowDisclosureEvent}to fire an expand/collapse event. In a custom method menuRowDisclosureEvent(RowDisclosureEvent disclosureEvent) I retreive the selected node and programatically change the icon. The only thing is that the tree view itself is not refreshed on the same phase cycle. The node icons are refreshed only at the next requests.
    Thanks,
    /Florin

    I have also tried to use:
    AdfFacesContext.getCurrentInstance().addPartialTarget(tree);Didn't helped

  • SwiXML - JTree LazyLoad Expand listener issue

    Hi,
    Iam creating UI using SwiXML which is based on Swing. Able to create a Tree structure using the below code logic. Issue is, unable to invoke expansion listener method.
    It would be great, if you can suggest on this issue.
    We have configured Java file in a xml file as below
    <scrollpane id="neh_task_tree">
    <gridbagconstraints insets="5,5,5,5" gridx="1" gridy="1" weightx="1.0"
    weighty="1.0" fill="GridBagConstraints.BOTH"
    anchor="GridBagConstraints.WEST"/>
    <tree id="neh_prod_activity_task_tree" initclass="com.oracle.appsfdoc.fusion.sos.LazyLoadDemo" Font="ARIAL-BOLD-14" VisibleRowCount="5"/>
    </scrollpane>
    public class LazyLoadDemo extends DefaultTreeModel {
            JTree tree;
            final TreeNode root;
            public LazyLoadDemo() {
                super(new DefaultMutableTreeNode("ROOT"));
                System.out.println("LazyLoadDemo");
                root = (DefaultMutableTreeNode) super.getRoot();
                createNodes(root);
                tree = new JTree((TreeNode)root);
                //tree.addTreeExpansionListener(this);
                //tree.addTreeWillExpandListener(this);
                System.out.println("BEFORE HANDLER");
                tree.addTreeExpansionListener(new TreeExpansionListener(){
                            @Override
                            public void treeCollapsed(TreeExpansionEvent e)
                                System.out.println("Node collapsed at " + e.getPath() + "\n");
                            @Override
                            public void treeExpanded(TreeExpansionEvent e)
                                System.out.println("Node expanded at " + e.getPath()+ "\n");
                        });            System.out.println("AFTER HANDLER");
        private void treeForumReviewTreeExpanded(javax.swing.event.TreeExpansionEvent evt) {//GEN-FIRST:event_treeForumReviewTreeExpanded
        // TODO add your handling code here:
        System.out.println("treeForumReviewTreeExpanded");
        /*DefaultMutableTreeNode node = (DefaultMutableTreeNode) evt.getPath().getLastPathComponent();
                ForumView fv = (ForumView) node.getUserObject();
            refreshReview(fv);*/
            private TreeNode createNodes(TreeNode root) {
                        DefaultMutableTreeNode grandparent;
                        DefaultMutableTreeNode parent;
                        DefaultMutableTreeNode child;
                        DefaultMutableTreeNode temp = (DefaultMutableTreeNode)root;
                        root = new DefaultMutableTreeNode("San Francisco");
                        grandparent = new DefaultMutableTreeNode("Potrero Hill");
                        temp.add(grandparent);
                        parent = new DefaultMutableTreeNode("Restaurants");
                        grandparent.add(parent);
                        child = new DefaultMutableTreeNode("Thai Barbeque");
                        parent.add(child);
                        child = new DefaultMutableTreeNode("Goat Hill Pizza");
                        parent.add(child);
                        parent = new DefaultMutableTreeNode("Grocery Stores");
                        grandparent.add(parent);
                        child = new DefaultMutableTreeNode("Good Life Grocery");
                        parent.add(child);
                        child = new DefaultMutableTreeNode("Safeway");
                        parent.add(child);
                        grandparent = new DefaultMutableTreeNode("Noe Valley");
                        temp.add(grandparent);
                        parent = new DefaultMutableTreeNode("Restaurants");
                        grandparent.add(parent);
                        child = new DefaultMutableTreeNode("Hamano Sushi");
                        parent.add(child);
                        child = new DefaultMutableTreeNode("Hahn's Hibachi");
                        parent.add(child);
                        parent = new DefaultMutableTreeNode("Grocery Stores");
                        grandparent.add(parent);
                        child = new DefaultMutableTreeNode("Real Foods");
                        parent.add(child);
                        child = new DefaultMutableTreeNode("Bell Market");
                        parent.add(child);
                        return root;
    Thanks in advance,
    Samba.

    Can some one help on this issue? Why Iam unable to invoke expand/collapse listeners with SwiXML?
    Thanks,
    Samba.

  • [Forum FAQ] How to use parameter to control the Expand/Collapse drill-down options in SSRS report?

    In SQL Server Reporting Services (SSRS), drill-down is an action we can apply to any report item to hide and show other report items. They all are ways that we can organize and display data to help our users understand our report better. In this article,
    we are talking about how to use parameter to control the Expand/Collapse drill-down options in SSRS report.
    Consider that the report has a dataset (dsSales) with following fields: SalesTerritoryGroup, SalesTerritoryCountry, CalendarYear, SalesAmount.
    1. The report has the following group settings:
    Parent Group: SalesTerritoryGroup
     Child Group: SalesTerritoryCountry
      Child Group: CalendarYear
       Details: SalesAmount
    2. Add three parameters in the report:
    GroupExpand:
    Available Values: “Specify values”
    Label: Yes           Value: Yes
    Label: No            Value: No
    Default Values: “Specify values”
    Value: Yes
    CountryExpand:
    Available Values: “Specify values”
    Label: Yes           Value: =IIF(Parameters!GroupExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No","No","Yes")
    YearExpand:
    Available Values: “Specify values”
    Label: Yes          
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No","No","Yes")
    3. Right click SalesTerritoryCountry icon in the Row Groups dialog box, select Group Properties.
    4. Click Visibility in the left pane. Select “Show or hide based on an expression” and type with following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", False, True)
    Select “Display can be toggled by this report item” option, and select “SalesTerritoryGroup” in the drop down list.
    5. Use the same method setting CalendarYear, (Details) drill-down with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", False, True)
    =IIF(Parameters!YearExpand.Value="Yes", False, True)
    6. Click SalesTerritoryGroup text box in the tablix. Select InitialToggleState property in the Properties dialog box, and type following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", True, False)
    7. Use the same method setting SalesTerritoryCountry, CalendarYear text box with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", True, False)
    =IIF(Parameters!YearExpand.Value="Yes", True, False)
    After that, when we preview the report, we can use these three parameters to expand/collapse drill-down.
    Note:
    In our test, we may meet following issue. We can check the expression of InitialToggleState property to troubleshooting the issue.
    Applies to
    Reporting Services 2008
    Reporting Services 2008 R2
    Reporting Services 2012

    In SQL Server Reporting Services (SSRS), drill-down is an action we can apply to any report item to hide and show other report items. They all are ways that we can organize and display data to help our users understand our report better. In this article,
    we are talking about how to use parameter to control the Expand/Collapse drill-down options in SSRS report.
    Consider that the report has a dataset (dsSales) with following fields: SalesTerritoryGroup, SalesTerritoryCountry, CalendarYear, SalesAmount.
    1. The report has the following group settings:
    Parent Group: SalesTerritoryGroup
     Child Group: SalesTerritoryCountry
      Child Group: CalendarYear
       Details: SalesAmount
    2. Add three parameters in the report:
    GroupExpand:
    Available Values: “Specify values”
    Label: Yes           Value: Yes
    Label: No            Value: No
    Default Values: “Specify values”
    Value: Yes
    CountryExpand:
    Available Values: “Specify values”
    Label: Yes           Value: =IIF(Parameters!GroupExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No","No","Yes")
    YearExpand:
    Available Values: “Specify values”
    Label: Yes          
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No","No","Yes")
    3. Right click SalesTerritoryCountry icon in the Row Groups dialog box, select Group Properties.
    4. Click Visibility in the left pane. Select “Show or hide based on an expression” and type with following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", False, True)
    Select “Display can be toggled by this report item” option, and select “SalesTerritoryGroup” in the drop down list.
    5. Use the same method setting CalendarYear, (Details) drill-down with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", False, True)
    =IIF(Parameters!YearExpand.Value="Yes", False, True)
    6. Click SalesTerritoryGroup text box in the tablix. Select InitialToggleState property in the Properties dialog box, and type following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", True, False)
    7. Use the same method setting SalesTerritoryCountry, CalendarYear text box with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", True, False)
    =IIF(Parameters!YearExpand.Value="Yes", True, False)
    After that, when we preview the report, we can use these three parameters to expand/collapse drill-down.
    Note:
    In our test, we may meet following issue. We can check the expression of InitialToggleState property to troubleshooting the issue.
    Applies to
    Reporting Services 2008
    Reporting Services 2008 R2
    Reporting Services 2012

  • JTree with XML content expand/collapse problem

    Hello all,
    I'm having this very weird problem with a JTree I use to display the contents of an XML file. I use the DOM parser (and not JDOM since I want the application to run as an applet as well, and don't want to have any external libraries for the user to download) and have a custom TreeModel and TreeNode implementations to wrap the DOM nodes so that they are displayed by the JTree.
    I have also added a popup menu in the tree, for the user to be able to expand/collapse all nodes under the selected one (i.e. a recursive method).
    When expandAll is run, everything works fine and the children of the selected node are expanded (and their children and so on).
    However, after the expansion when I run the collapseAll function, even though the selected node collapses, when I re-expand it (manually not by expandAll) all of it's children are still fully open! Even if I collapse sub-elements of the node manually and then collapse this node and re-expand it, it "forgets" the state of it's children and shows them fully expanded.
    In other words once I use expandAll no matter what I do, the children of this node will be expanded (once I close it and re-open it).
    Also after running expandAll the behaviour(!) of the expanded nodes change: i have tree.setToggleClickCount(1); but on the expanded nodes I need to double-click to collapse them.
    I believe the problem is related to my implementations of TreeModel and TreeNode but after many-many hours of trying to figure out what's happening I'm desperate... Please help!
    Here's my code:
    public class XMLTreeNode implements TreeNode 
         //This class wraps a DOM node
        org.w3c.dom.Node domNode;
        protected boolean allowChildren;
        protected Vector children;
        //compressed view (#text).
         private static boolean compress = true;   
        // An array of names for DOM node-types
        // (Array indexes = nodeType() values.)
        static final String[] typeName = {
            "none",
            "Element",
            "Attr",
            "Text",
            "CDATA",
            "EntityRef",
            "Entity",
            "ProcInstr",
            "Comment",
            "Document",
            "DocType",
            "DocFragment",
            "Notation",
        static final int ELEMENT_TYPE =   1;
        static final int ATTR_TYPE =      2;
        static final int TEXT_TYPE =      3;
        static final int CDATA_TYPE =     4;
        static final int ENTITYREF_TYPE = 5;
        static final int ENTITY_TYPE =    6;
        static final int PROCINSTR_TYPE = 7;
        static final int COMMENT_TYPE =   8;
        static final int DOCUMENT_TYPE =  9;
        static final int DOCTYPE_TYPE =  10;
        static final int DOCFRAG_TYPE =  11;
        static final int NOTATION_TYPE = 12;
        // The list of elements to display in the tree
       static String[] treeElementNames = {
            "node",
      // Construct an Adapter node from a DOM node
      public XMLTreeNode(org.w3c.dom.Node node) {
        domNode = node;
      public String toString(){
           if (domNode.hasAttributes()){
                return domNode.getAttributes().getNamedItem("label").getNodeValue();
           }else return domNode.getNodeName();      
      public boolean isLeaf(){ 
           return (this.getChildCount()==0);
      boolean treeElement(String elementName) {
          for (int i=0; i<treeElementNames.length; i++) {
            if ( elementName.equals(treeElementNames)) return true;
    return false;
    public int getChildCount() {
         if (!compress) {   
    return domNode.getChildNodes().getLength();
    int count = 0;
    for (int i=0; i<domNode.getChildNodes().getLength(); i++) {
    org.w3c.dom.Node node = domNode.getChildNodes().item(i);
    if (node.getNodeType() == ELEMENT_TYPE
    && treeElement( node.getNodeName() ))
    // Note:
    // Have to check for proper type.
    // The DOCTYPE element also has the right name
    ++count;
    return count;
    public boolean getAllowsChildren() {
         // TODO Auto-generated method stub
         return true;
    public Enumeration children() {
         // TODO Auto-generated method stub
         return null;
    public TreeNode getParent() {
         // TODO Auto-generated method stub
         return null;
    public TreeNode getChildAt(int searchIndex) {
    org.w3c.dom.Node node =
    domNode.getChildNodes().item(searchIndex);
    if (compress) {
    // Return Nth displayable node
    int elementNodeIndex = 0;
    for (int i=0; i<domNode.getChildNodes().getLength(); i++) {
    node = domNode.getChildNodes().item(i);
    if (node.getNodeType() == ELEMENT_TYPE
    && treeElement( node.getNodeName() )
    && elementNodeIndex++ == searchIndex) {
    break;
    return new XMLTreeNode(node);
    public int getIndex(TreeNode tnode) {
         if (tnode== null) {
              throw new IllegalArgumentException("argument is null");
         XMLTreeNode child=(XMLTreeNode)tnode;
         int count = getChildCount();
         for (int i=0; i<count; i++) {
              XMLTreeNode n = (XMLTreeNode)this.getChildAt(i);
              if (child.domNode == n.domNode) return i;
         return -1; // Should never get here.
    public class XMLTreeModel2 extends DefaultTreeModel
         private Vector listenerList = new Vector();
         * This adapter converts the current Document (a DOM) into
         * a JTree model.
         private Document document;
         public XMLTreeModel2 (Document doc){
              super(new XMLTreeNode(doc));
              this.document=doc;
         public Object getRoot() {
              //System.err.println("Returning root: " +document);
              return new XMLTreeNode(document);
         public boolean isLeaf(Object aNode) {
              return ((XMLTreeNode)aNode).isLeaf();
         public int getChildCount(Object parent) {
              XMLTreeNode node = (XMLTreeNode) parent;
    return node.getChildCount();
         public Object getChild(Object parent, int index) {
    XMLTreeNode node = (XMLTreeNode) parent;
    return node.getChildAt(index);
         public int getIndexOfChild(Object parent, Object child) {
    if (parent==null || child==null )
         return -1;
              XMLTreeNode node = (XMLTreeNode) parent;
    return node.getIndex((XMLTreeNode) child);
         public void valueForPathChanged(TreePath path, Object newValue) {
    // Null. no changes
         public void addTreeModelListener(TreeModelListener listener) {
              if ( listener != null
    && ! listenerList.contains( listener ) ) {
    listenerList.addElement( listener );
         public void removeTreeModelListener(TreeModelListener listener) {
              if ( listener != null ) {
    listenerList.removeElement( listener );
         public void fireTreeNodesChanged( TreeModelEvent e ) {
    Enumeration listeners = listenerList.elements();
    while ( listeners.hasMoreElements() ) {
    TreeModelListener listener =
    (TreeModelListener) listeners.nextElement();
    listener.treeNodesChanged( e );
         public void fireTreeNodesInserted( TreeModelEvent e ) {
    Enumeration listeners = listenerList.elements();
    while ( listeners.hasMoreElements() ) {
    TreeModelListener listener =
    (TreeModelListener) listeners.nextElement();
    listener.treeNodesInserted( e );
         public void fireTreeNodesRemoved( TreeModelEvent e ) {
    Enumeration listeners = listenerList.elements();
    while ( listeners.hasMoreElements() ) {
    TreeModelListener listener =
    (TreeModelListener) listeners.nextElement();
    listener.treeNodesRemoved( e );
         public void fireTreeStructureChanged( TreeModelEvent e ) {
    Enumeration listeners = listenerList.elements();
    while ( listeners.hasMoreElements() ) {
    TreeModelListener listener =
    (TreeModelListener) listeners.nextElement();
    listener.treeStructureChanged( e );
    The collapseAll, expandAll code (even though I m pretty sure that's not the problem since they work fine on a normal JTree):
        private void collapseAll(TreePath tp){
             if (tp==null) return;
             Object node=tp.getLastPathComponent();
             TreeModel model=tree.getModel();
             if (!model.isLeaf(node)){
                  tree.collapsePath(tp);
                  for (int i=0;i<model.getChildCount(node);i++){
                  //for (int i = node.childCount()-4;i>=0;i--){
                       collapseAll(tp.pathByAddingChild(model.getChild(node,i)));
                  tree.collapsePath(tp);
        private void expandAll(TreePath tp){
             if (tp==null) return;
             Object node=tp.getLastPathComponent();
             TreeModel model=tree.getModel();
             if (!model.isLeaf(node)){
                  tree.expandPath(tp);
                  for (int i=0;i<model.getChildCount(node);i++){
                  //for (int i = node.childCount()-4;i>=0;i--){
                       expandAll(tp.pathByAddingChild(model.getChild(node,i)));

    Hi,
    Iam not facing this problem. To CollapseAll, I do a tree.getModel().reload() which causes all nodes to get collapsed and remain so even if I reopen them manually.
    Hope this helps.
    cheers,
    vidyut

Maybe you are looking for

  • How to change the display view of the records and modified into a row

    I have a SQL which can count the condition(Bad,Poor,Worse) in a day and group it into a month and displays as follows: YEARS MONTHS LV    COUNTVAL 2009 Apr    Bad          5 2009 Apr    Poor         3 2009 Apr    Worse        2 2009 Aug    Bad       

  • Broadband Drop Outs

    Hey guys   Looking for some advice.  Currently living in a house with BT Infinity (its rented so I'm not the bill payer), when Infinity was installed everything worked fine - no problems at all.  Recently however (and I'm not convinced something hasn

  • Adobe Camera Raw and using a Canon 5D Mark2

    I wanted to share my learning curve about this problem for CS3 users and below who use a Canon 5dMk 2. My previous workflow had been to convert all my CR2 files to Adobe DNG using Lightroom version 2 which works fine. However I have started using DXO

  • How to use backing store in JPanel?

    Below is a sketch of a class that extends JPanel. If I remove the variable "draw", the class works fine, except that the graphics drawing code is executed every time the parent window is fronted, resized, etc. I introduced the variable "draw" hoping

  • Cisco 1141N AP upgrading from 12.4 to the latest version 12.x

    Hi, I purchased the 1141n AP.  Last year when in May, I called Cisco support for help.  He told me it, the 1141n  would not works alone, it needs the controller.  However, He also stated that the new version of IOS will be working as the access point