cancel
Showing results for 
Search instead for 
Did you mean: 

TreeView not showing child nodes

Former Member
0 Kudos

I've created a component to display a tree view of some information returned from an EJB. In the wdDoInit of the controller, I populate the first set of nodes as follows:

loadChildren(wdContext.nodePreference(), 0);

The '0' signifies the root node of the tree. The loadChildren() method looks as follows:

void loadChildren(IPublicTreeComp.IPreferenceNode node, int nodeId) {		
  NodeInfo[] nodes = getNodes(nodeId);
  for (int i = 0; i < nodes.length; ++i) {
    IPreferenceElement elt = node.createPreferenceElement();
    elt.setNodeId(nodes<i>.getNodeId());
    elt.setNodeName(nodes<i>.getNodeName());
    elt.setHasChildren(nodes<i>.isFolderNode());
    elt.setExpanded(false);
    node.addElement(elt);
  }
}

In the view component, the loadChildren action is tied to this code:

wdThis.wdGetTreeCompController().loadChildrenForNode(element.mappedPreferenceElement());

And finally, loadChildrenForNode() is defined as follows:

public void loadChildrenForNode( ca.huskyenergy.glob.prefs.editor.wdp.IPublicTreeComp.IPreferenceElement element )
  {
    //@@begin loadChildrenForNode()
    loadChildren(element.nodeChild(), element.getNodeId());
    //@@end
  }

All the methods are invoked when they should be - I can see that the correct data is being fetched and stored into the context, but other than the top two tree nodes, no other nodes are displayed when the root nodes are expanded.

What am I missing?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Kevin,

Just a silly guess -- did you bind Expanded property of TreeNodeItem to Expanded attribute of node?

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

I got busy on other things, so I was unable to get back to this thread.....however, I'm back at it again.

Yes, the expanded property is bound, and is set to true when the LoadChildren() action is triggered. I can see that elements are added to the recursion node, but the UI is not updated.

Former Member
0 Kudos

What about the "hasChildren" property of the TreeNodeType? Is it bound to a context attribute?

Armin

Former Member
0 Kudos

No, actually it was simpler than that.

The context that held the data was created in the controller. I had to create a recursion node in the view. Once I did that, I tree was displayed correctly.

I now have two questions:

Why do we have to re-create the recursion node in the view?

If I add or remove elements in an already opened node, how do I invalidate the context to force a reload of that particular node?

Former Member
0 Kudos

Ken,

Does your node in view mapped to node in component controller? Or you are copying elements manually?

VS

Former Member
0 Kudos

It's mapped, but I can't select the recursion node to map it. I have to create that in the view Context.

Former Member
0 Kudos

Ken,

Ok, you must create recursion node in view controller context even if recursive node is mapped. Just take it "as is" -- I don't know the reason why it's necessary.

But why you are copying elements manually even if your recursive node is mapped? Airn't them populated automatically?

VS

Former Member
0 Kudos

I'm not sure what you mean by 'copying manually' - nothing is being copied between the contexts.

Former Member
0 Kudos

Ouch, I've overlooked that you delegates task of node population to component controller.

Then, getting back to your original question, you may just remove necessary elements from either node in view or component controller -- as long as they are mapped both stay in synch.

Invalidation is also possible over any of both nodes. Just drill down to necessary element in recursive node (serves as parent), then get it's recursion node (something like parentEl.nodeSubelements()) and call invalidate on result.

Valery Silaev

SaM Solutions

http://www.sams-solutions.net

Answers (0)