1 2 Previous Next 19 Replies Latest reply on Aug 4, 2015 5:21 AM by askkuber Go to original post
      • 15. Re: Expanding richtree and then refresh after that expand collapse images gone?
        askkuber

        Can you please guide how to do that?

        • 16. Re: Expanding richtree and then refresh after that expand collapse images gone?
          michpetrov

          Use a4j:log and set level to debug (put it outside of the render area), you will see a message starting with "Server returned responseText:" and following is the response, your browser's developer tools should also have a network tab where you can see the requests.

          • 17. Re: Expanding richtree and then refresh after that expand collapse images gone?
            askkuber

            I tried below code to collapse programmatically, but didn't work.

            List<UIComponent> uicomponent = treeBindingCust.getChildren();

                    for(UIComponent obj:uicomponent){

                        if(obj instanceof UITreeModelRecursiveAdaptor){

                            UITreeModelRecursiveAdaptor uITreeModelRecursiveAdaptor = (UITreeModelRecursiveAdaptor) obj;

                            List<UIComponent> uicomponentrecusrsiveAdaptor = uITreeModelRecursiveAdaptor.getChildren();

                            for(UIComponent objRecursive : uicomponentrecusrsiveAdaptor){

                                if(objRecursive instanceof UITreeNode){

                                    UITreeNode uITreeNode = (UITreeNode)objRecursive;

                                    uITreeNode.setExpanded(false);

                                   

                                }                   

                            }

                           

                        }

                    }

             

            Is there anything that I can add?

            • 18. Re: Expanding richtree and then refresh after that expand collapse images gone?
              michpetrov

              getChildren() works over the tree representation of the components, If you have a tree defined likes this:

              <rich:tree>

                  <rich:treeNode />

              </rich:tree>

              then calling tree.getChildren() returns just that one node.

               

              Use a method like visitTree() to go over the data model:

              tree.visitTree(VisitContext.createVisitContext(FacesContext.getCurrentInstance()), new VisitCallback() {
                  @Override
                  public VisitResult visit(VisitContext context, UIComponent target) {
                      if (target instanceof UITreeNode) {
                          ((UITreeNode) target).setExpanded(false);
                      }
              
                      return VisitResult.ACCEPT;
                  }
              });
              
              • 19. Re: Expanding richtree and then refresh after that expand collapse images gone?
                askkuber

                Hi Michal Petrov,

                 

                             Thank you very much for the above solution. When I added its working, but its failing in one scenario. I have 6 tabs, when I click on the refresh button it should collapse all 6 tabs and it should show + button. But for 6th tab, its not showing + button for some nodes. Please find the code which I am using below. Please let me know is there anything I need to  put.

                 

                //Code to collapse tree

                        VisitCallback visitCallback = new VisitCallback() { 

                            @Override 

                            public VisitResult visit(VisitContext context, UIComponent target) { 

                                if (target instanceof UITreeNode) { 

                                    ((UITreeNode) target).setExpanded(false); 

                                } 

                         

                                return VisitResult.ACCEPT; 

                            } 

                        };

                               

                        treeBindingCust.visitTree(VisitContext.createVisitContext(FacesContext.getCurrentInstance()), visitCallback);

                        treeBindingServ.visitTree(VisitContext.createVisitContext(FacesContext.getCurrentInstance()), visitCallback);

                        treeBindingNw.visitTree(VisitContext.createVisitContext(FacesContext.getCurrentInstance()), visitCallback);

                        treeBindingLink.visitTree(VisitContext.createVisitContext(FacesContext.getCurrentInstance()), visitCallback);

                        treeBindingLoc.visitTree(VisitContext.createVisitContext(FacesContext.getCurrentInstance()), visitCallback);

                        treeBinding.visitTree(VisitContext.createVisitContext(FacesContext.getCurrentInstance()), visitCallback);

                1 2 Previous Next