-
15. Re: Expanding richtree and then refresh after that expand collapse images gone?
askkuber Jul 23, 2015 9:16 AM (in response to michpetrov)Can you please guide how to do that?
-
16. Re: Expanding richtree and then refresh after that expand collapse images gone?
michpetrov Jul 23, 2015 9:43 AM (in response to askkuber)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 Jul 30, 2015 4:08 AM (in response to michpetrov)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 Jul 30, 2015 11:14 AM (in response to askkuber)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 Aug 4, 2015 5:21 AM (in response to michpetrov)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);