Looking for help with groovy

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Looking for help with groovy

Marius Dumitru Florea
On Fri, Mar 28, 2014 at 2:55 PM, DeHaynes <[hidden email]> wrote:

> 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.

Hope this helps,
Marius

>
> If that is right, then wouldn't I need change where I get the data in the
> list above also?
>
>
>
> --
> View this message in context: http://xwiki.475771.n2.nabble.com/Looking-for-help-with-groovy-tp7589782p7589856.html
> Sent from the XWiki- Dev mailing list archive at Nabble.com.
> _______________________________________________
> devs mailing list
> [hidden email]
> http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/devs
Reply | Threaded
Open this post in threaded view
|

Re: Looking for help with groovy

DeHaynes
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?

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Looking for help with groovy

DeHaynes
In reply to this post by Marius Dumitru Florea
Reply | Threaded
Open this post in threaded view
|

Re: Looking for help with groovy

Guillaume "Louis-Marie" Delhumeau
Nice work! Good to see this contribution!


2014-04-01 19:30 GMT+02:00 DeHaynes <[hidden email]>:

> I created an extension entry
>
> http://extensions.xwiki.org/xwiki/bin/view/Extension/Self-Renaming+Forms
>
>
>
>
> --
> View this message in context:
> http://xwiki.475771.n2.nabble.com/Looking-for-help-with-groovy-tp7589782p7589886.html
> Sent from the XWiki- Dev mailing list archive at Nabble.com.
> _______________________________________________
> devs mailing list
> [hidden email]
> http://lists.xwiki.org/mailman/listinfo/devs
>
_______________________________________________
devs mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/devs
12