Andrea, I think Patrizio's solution is the way to do it if the tree is rendered. The problem I run into often is this: Many actions are triggered asynchronously by user actions. If the cascade call happens before the tree is rendered, which can happen if it is triggered by a user action, then the cascade itself will fail probably along with the call to see if the node is checked, because the entire logic depends on the tree being rendered.
But if you are certain that the cascade call will never be triggered before the tree is rendered, then you can safely use the cascade call and other methods like isChecked(), etc . At least this has been my experience....I have sections in my code for each panel where I know I can safely call methods like this because the widget is rendered for sure. At other places I stay away from these calls, because they crash the browser Java script engine in a way that is awfully hard to debug (because there is no exception trace or almost any useful info about how the error happened). -kornel On Thu, Jul 9, 2009 at 8:21 AM, Roundcrisis <[email protected]> wrote: > Hi Kornel > Thanks for the pointer, > however not sure I follow. you cant check or uncheck a node that is not > rendered, right? > so i would imagine this cant happen... > Cheers > > > Andrea > > > > > On Thu, Jul 9, 2009 at 12:45 PM, Kornel Csaszar <[email protected]> wrote: > >> Andrea, >> It's good to be careful with getting info back from widgets like that. If >> the widget >> is not yet rendered you will get a very nasty general error (yellow >> triangle). >> >> If you need that info and you are not certain the component >> will have been rendered by that time, it's often best to keep collections >> of >> objects on your own of the tree node references. >> >> -kornel >> >> >> On Mon, Jul 6, 2009 at 10:30 AM, Roundcrisis <[email protected]>wrote: >> >>> Yeah that does work thanks :D >>> Andrea >>> >>> >>> >>> >>> On Mon, Jul 6, 2009 at 12:57 PM, Patrizio De Michele < >>> [email protected]> wrote: >>> >>>> hi, >>>> maybe you can use this code, try it and make me know: >>>> >>>> final List<Node> checkedNodes = new ArrayList<Node>(); >>>> final List<Node> allNodes = new ArrayList<Node>(); >>>> treePanel.getRootNode().cascade(new NodeTraversalCallback() { >>>> public boolean execute(Node node) { >>>> if (Boolean.valueOf(node.getAttribute("checked"))) { >>>> checkedNodes.add(node); >>>> } >>>> allNodes.add(node); >>>> return true; >>>> } >>>> }); >>>> >>>> bye Patrizio >>>> >>>> >>>> 2009/7/6 Andrea <[email protected]> >>>> >>>> >>>>> Hi there >>>>> >>>>> I m using a TreePanel that can be checked; and was wondering what is >>>>> the best way to get info back from the tree: ie all nodes whether they >>>>> are checked or not , and I would like to know if they are. >>>>> >>>>> I know i can use treePanel.getChecked() but that only gets me the >>>>> checked ones >>>>> or I can use root.getChildNodes() but here I m not terribly sure how >>>>> to know if its checked or not, it also seems quite cumbersome to >>>>> navigate the tree structure this way >>>>> >>>>> any other alternatives? or recomended way to deal with trees in >>>>> general? >>>>> >>>>> >>>>> Thanks >>>>> >>>>> >>>> >>>> >>>> >>> >>> >>> >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "GWT-Ext Developer Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/gwt-ext?hl=en -~----------~----~----~----~------~----~------~--~---
