length; i++) {
var nodeID = inNodeID + i + inResp[i].name;
// Add the subdirectory to its parent.
directoryTree.insertNewChild(inNodeID, nodeID,
inResp[i].name, 0, "folderClosed.gif", "folderOpen.gif",
"folderClosed.gif", 0, 0);
// Set path of root on node for later.
directoryTree.setUserData(nodeID, "path", inResp[i].path);
// If the subdirectory itself has subdirectories, add the
// "Loading" dummy node so that when they expand the node they'll
// see this until the contents load.
if (inResp[i].hasChildren) {
directoryTree.insertNewChild(nodeID, nodeID + "_dummy",
"Loading...", 0, "blank.gif", 0, 0, 0, 0);
directoryTree.closeItem(nodeID);
CHAPTER 6 n REMOTELY MANAGING YOUR FILES: DWR FILE MANAGER 299
}
}
// Delete the "Loading" node.
directoryTree.deleteItem(inNodeID + "_dummy");
}
}
);
}
return true;
} // End directoryExpanded().
The first thing that??™s done is a check: is the very first child node of the selected node the
???Loading??? node? Only in this case do we have work to do because it means we haven??™t yet populated
this branch of the tree.
Assuming we have work to do, that work begins by getting the path of the expanded
directory. That information is passed as a parameter to the listDirectories() method of the
FileSystemFunctions remote class.
Pages:
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538