> I don't understand.
> All of the following pieces of data are being pulled from source variable,
> which is passed in by the XWiki system as a parameter in the onEvent method:
> * The wiki document
> * The value of the processName field in the wiki document.
> * The wiki document's name.
> * The document Title
> * The documents Dirty flags.
> * The URL for the document.
> And what I think you are telling me is that the source is not a reliable
> place for getting the document space, because in the future sub-wikis will
> cause an issue. Is that right?
No! My comment was only about:
// Build the new name for the document in the format of "SpaceName.PageName".
def FullDocumentName = source.getSpaceName() + "." + NewDocumentName;
The format you are referring to is called "document reference". It's
actually a string representation of a document reference. It's no
recommended to build the string representation of a document reference
manually by concatenating strings. The space or page name could
contain a dot (in which case it would need to be escaped). Or the
format could be changed at some point. That's why I recommended you to
use a document reference instead. Note that the rename method that
accepts a string (which you are using) is deprecated in favor of the
signature that accepts a document reference. So you just have to
replace FullDocumentName with a document reference.
Thank you for the explanation. I have modified the code to use DocumentReferences. I am still having one issue. When the user clicks the "Save & Continue" an Ajax update is done. The code works as expected and renames the document, but because it is Ajax, the page is not updated. So the user:
1. Does not see the title change.
2. Thinks they are still editing the original document.
I see that I have two choices.
1. Disable and hide the "Save & Continue" button.
2. Look into modifying the Ajax update process somehow.
I would prefer the second option as it is the correct way to handle this. Do you have a suggestion on which way to go and could you point me to something to get me started?