Prev | Current Page 532 | Next

Frank Zammetti

"Practical DWR 2 Projects"


CHAPTER 6 n REMOTELY MANAGING YOUR FILES: DWR FILE MANAGER 302
The first thing we need to do is check that we??™re in stage 2. The reason for doing so is
because this method will be called a total of three times for an edit: once before the editing
begins, once when the cell editor is opened, and once when it closes. For our purposes here,
we only care about that last stage, which is stage 2 (the stages go in the order stated here and
are 0-based).
Once we confirm it??™s time to actually do the rename, we then go ahead and begin by getting
the node of the selected directory in the tree. We then get the path of that directory by
looking up the path user data attribute via the getUserData() method of the tree component.
Next, we construct the full path to the item as it was originally named. As you can see, one of
the parameters to this event-handler function is the old value of the edited cell. We do the
same for the new name of the item, so the end result is two variables, oldFullPath and
newFullPath, which represent the fully qualified path and name of the file or directory being
renamed, both before and after the edit.
After that, it??™s a simple matter of a DWR call to the renameFile() method of the
FileSystemFunctions class, passing it those two paths.


Pages:
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544