My understanding of the semantics of node.isLeaf() is that it returns true if the node has children (whether fetched or not) and false if the node has no children.
My understanding of the semantics of node.getChildCount() is that it can return the number of children fetched or the number of children to be fetched, depending upon the needs of the application. I haven't gone through all the Tree2 code, so I'm a little unclear why getChildCount() has to be part of the TreeNode interface. With this in mind, I would think that most boolean decisions that are based upon whether a node has children should be based upon the node.isLeaf() method, not the node.getChildCount() method. Are there other interpretations out there about the semantics of these two methods? Thanks, - Brendan -----Original Message----- From: CONNER, BRENDAN (SBCSI) Sent: Wednesday, August 03, 2005 10:23 AM To: 'MyFaces Development'; 'Sean Schofield' Subject: RE: [jira] Commented: (MYFACES-350) Use 'node.isLeaf()' in tree2 to decide whether to display the navigation icon But if the node is empty, wouldn't isLeaf() return true? And in that case, wouldn't the + sign be suppressed? I'm just trying to understand the test case that failed. Thanks, - Brendan -----Original Message----- From: Sean Schofield [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 02, 2005 7:23 PM To: MyFaces Development Subject: Re: [jira] Commented: (MYFACES-350) Use 'node.isLeaf()' in tree2 to decide whether to display the navigation icon Well this situation where it doesn't work so well is basically the exact opposite of your situation. If you know the entire contents of the tree ahead of time and you don't want to show a '+' icon for an empty node that *could* potentially have nodes but doesn't. In the case of the simple examples, you don't want '+' icons for empty folders. Could your application work if you didn't rely on the navigation icons? (Just used actionListeners for your folders or whatever?) Just curious. I'm not suggesting you resort to that. I'm thinking that we could make it an option to hide/suppress navigation icons for empty nodes so both sides are happy. sean On 8/2/05, CONNER, BRENDAN (SBCSI) <[EMAIL PROTECTED]> wrote: > But that will impact our application, because, with lazy fetches, we > sometimes have leaf = false and childCount = 0 (because the children > have not yet been fetched). In such cases, we need the + icon to show, > because there are children yet to be fetched. If we suppress the + sign > if either leaf = false or childCount = 0, then none of our nodes will > have + icons (because, at the beginning, nothing has been fetched). > > Under what conditions was the previous fix failing? > > - Brendan > > -----Original Message----- > From: sean schofield (JIRA) [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 02, 2005 5:51 PM > To: [email protected] > Subject: [jira] Commented: (MYFACES-350) Use 'node.isLeaf()' in tree2 to > decide whether to display the navigation icon > > > [ > http://issues.apache.org/jira/browse/MYFACES-350?page=comments#action_12 > 317456 ] > > sean schofield commented on MYFACES-350: > ---------------------------------------- > > OK this fix caused another problem (see related issue) so I made an > additional change: > > bitMask += (node.isLeaf() || node.getChildCount() == 0) ? NOTHING : > CHILDREN; > > This should still solve the original problem without causing any new > ones. > > > Use 'node.isLeaf()' in tree2 to decide whether to display the > navigation icon > > > ------------------------------------------------------------------------ > ----- > > > > Key: MYFACES-350 > > URL: http://issues.apache.org/jira/browse/MYFACES-350 > > Project: MyFaces > > Type: Improvement > > Versions: Nightly Build > > Environment: IBM RAS using MyFaces JSF implementation > > Reporter: Brendan Conner > > Priority: Minor > > Fix For: Nightly Build > > > > > I would like to suggest the following enhancement to Tree2 that would > make it more amenable to grabbing data "on the fly" as the user is > expanding nodes. Here's the problem: > > Currently, Tree2 does not display the + navigation icon if the number > of child nodes is zero, regardless of whether there are children yet to > be fetched. What I'd like to have happen is that the + navigation icon > is displayed only if the node is not a leaf node, regardless of whether > there are currently child nodes. > > In other words, I would like to have the following line in > HtmlRenderer.encodeNavigation() changed from: > > bitMask += (node.getChildCount()>0) ? CHILDREN : NOTHING; > > to: > > bitMask += (node.isLeaf) ? CHILDREN : NOTHING; > > If we make this change, then the application developer has more > control over whether the + navigation symbol appears, since the > application developer can override the isLeaf() method in the node > itself. > > Currently, the workaround is to override the node's getChildCount() > method to return the number of records *expected* if the user were to > request the fetch. However, the "expected" number of records is not > always known, so, in these cases, getChildCount() would have to be coded > to return an arbitrary number greater than zero, which is kind of a > kluge. > > -- > This message is automatically generated by JIRA. > - > If you think it was sent incorrectly contact one of the administrators: > http://issues.apache.org/jira/secure/Administrators.jspa > - > For more information on JIRA, see: > http://www.atlassian.com/software/jira > >
