Yes, my scheduler can contain: xcontext.put("DoCleanup", "true")
xwiki.getDocument("SandboxTemplate.ReinitSandboxMacro").getRenderedContent()
or this
xcontext.put("source", "SpaceTemplate")
xcontext.put("DoCleanup", "true")
xwiki.getDocument("SandboxTemplate.ReinitSandboxMacro").getRenderedContent()
or
xcontext.put("source", "SpaceTemplate")
xcontext.put("target", "SpaceToDeleteAndOverwrite")
xcontext.put("DoCleanup", "true")
xwiki.getDocument("SandboxTemplate.ReinitSandboxMacro").getRenderedContent()
And my SandboxTemplate.ReinitSandboxMacro contain this velocity scipt:
#if ($request.get('source') != $null)
#set ($Source = "$request.get('source')")
#else
#set ($Source = "SandboxTemplate")
#end
#if ($request.get('target') != $null)
#set ($Target = "$request.get('target')")
#else
#set ($Target = "Sandbox")
#end
#if ($request.confirm == 'true' || $xcontext.get("docleanup") ==
'true')
=>My script is launch
This test doesn't work
#if (xcontext.get("source") != $null)
#set ($Source = "xcontext.get("source")")
#else
#set ($Source = "SandboxTemplate")
#end
To resume: I'm looking for a test to know if a xcontext.get("parameter")
exist or not (in a velocity script)
________________________________
De : Thomas Mortagne <thomas.mortagne(a)xwiki.com>
À : Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr>fr>; XWiki Users <users(a)xwiki.org>
Envoyé le : Vendredi 1 août 2014 15h28
Objet : Re: [xwiki-users] How to check $xcontext.get(xxxx) is empty?
It's not very clear how exactly are you executing this wiki content
with Velocity in it ? Document#getRenderedContent call from Groovy ?
On Fri, Aug 1, 2014 at 3:16 PM, Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr> wrote:
Hello,
I have "some" difficulty with my groovy/velocity code:
I manage to pass some parameter between my scheduler/groovy script to my velocity code of
my page but I need to check in my velocity code if my parameter exist (or not).
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Cont…
By exemple, this code doesn't work:
{{velocity}}
#if ( $xcontext.get("DoCleanup")!=$null)
"DoCleanup" parameter doesn't exist
#else
DoCleanup parameter from groovy code is $xcontext.get("DoCleanup")
#end
{{/velocity}}
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Cont…
return null if user have PR :-(
In fact, in my velocity code I need to detect who's launch the velocity script:
groovy code of scheduler or manually launch by the page containing velocity code.
Any idea how can I do?
Thxs.
Pascal B.
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne