Nevermind, found the problem by looking at the tree2 renderer. It was
calling getChildCount before getChildren. So I was returning 1 as the
child count, but returning no children, which it didn't like. Since I
had an isExpanded method on my custom tree node, I could simply load
the nodes in the getChildCount instead of getChildren():
/**
* @see org.apache.myfaces.custom.tree2.TreeNode#getChildCount()
*/
public int getChildCount()
{
if (children == null && !isExpanded())
return 1;
return getChildren().size();
}
public List<WebReadyTreeNode> getChildren()
{
if (children == null)
children = loadChildren(this);
return children;
}
-Andrew
On 6/19/06, Andrew Robinson <[EMAIL PROTECTED]> wrote:
I am creating a tree that I am dynamically loading the children for.
Each list of children for a node represents a web service call that I
must make, so I don't know how many children are present until the
children are loaded. I was trying to lazy load these guys based on
when they are asked for (so I put the loading code in the
getChildren() method).
To make sure the '+' sign was drawn, I returned '1' as the child count
if the children were not loaded. I made it so toggling expansion is
done via AJAX. The problem occurs if I exand a node with no children.
Example (before):
- A
+ B
+ C
I click on the + for 'B' which actually has no children on the server and I get:
- A
- B
- B
- B
- B
The grid lines get lost 'in space' after B, and C is never rendered.
If I refresh the page, the tree is accurate:
-A
-B
+C
It just really doesn't like me reporting '1' as the child count and
then returning 0 children later. Is there a way I can get it to accept
this fake node count and not blow up upon re-render? I would rather
not have to pre-pull one more level from the server if I don't have to
(in this case, I would have to load B and C which would be 2 web
service calls, so depending on the number of children, that could end
up being several web service calls and not good for performance).
Thanks,
Andrew