on 01-10-2007 5:29 PM
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?
Kevin,
Just a silly guess -- did you bind Expanded property of TreeNodeItem to Expanded attribute of node?
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.