[xwiki-users] How to check $xcontext.get(xxxx) is empty?
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/Conte... 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/Conte... 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.
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 <[email protected]> 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/Conte...
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/Conte... 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
And also, what is your target XWiki version ? Is it really 4.1 ? On Fri, Aug 1, 2014 at 3:28 PM, Thomas Mortagne <[email protected]> wrote:
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 <[email protected]> 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/Conte...
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/Conte... 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
-- Thomas Mortagne
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 <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]> 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 <[email protected]> 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/Conte...
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/Conte... 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
No I use Xwiki 6.1 but I follow this link for documentation: http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation ________________________________ De : Thomas Mortagne <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]> Envoyé le : Vendredi 1 août 2014 15h29 Objet : Re: [xwiki-users] How to check $xcontext.get(xxxx) is empty? And also, what is your target XWiki version ? Is it really 4.1 ? On Fri, Aug 1, 2014 at 3:28 PM, Thomas Mortagne <[email protected]> wrote:
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 <[email protected]> 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/Conte...
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/Conte... 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
-- Thomas Mortagne
So you want to differenciate between a property set to null and a property that does not exist ? If your issue is that the document may not have PR then you can't use custom properties in Contex to passe informations since there won't be any way to access it. Another way that should do it is to set properties in script context using something like: services.component.getInstance(org.xwiki.script.ScriptContextManager.class).setAttribute("DoCleanup", true, javax.script.ScriptContext.ENGINE_SCOPE); and then access it in Velocity using: $DoCleanup On Fri, Aug 1, 2014 at 3:46 PM, Pascal BASTIEN <[email protected]> wrote:
No I use Xwiki 6.1 but I follow this link for documentation: http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation
________________________________ De : Thomas Mortagne <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]> Envoyé le : Vendredi 1 août 2014 15h29
Objet : Re: [xwiki-users] How to check $xcontext.get(xxxx) is empty?
And also, what is your target XWiki version ? Is it really 4.1 ?
On Fri, Aug 1, 2014 at 3:28 PM, Thomas Mortagne <[email protected]> wrote:
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 <[email protected]> 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/Conte...
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/Conte... 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
-- Thomas Mortagne
-- Thomas Mortagne
Hi, 2014-08-01 15:42 GMT+02:00 Pascal BASTIEN <[email protected]>:
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()
I would maybe try to replace the "...getRenderedContent()" by an include macro [1] like: {{include reference="SandboxTemplate.ReinitSandboxMacro"/}} include macro renders the document in same context as container document. [1] - http://extensions.xwiki.org/xwiki/bin/view/Extension/Include+Macro
And my SandboxTemplate.ReinitSandboxMacro contain this velocity scipt:
#if ($request.get('source') != $null)
If from outside you use "$xcontext.put", you can't expect it to be available from "$request.get" ;-) You should use "$xcontext.get" here instead.
#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')
From where would come this "confirm" request param ? From a scheduler job there will not be such request parameter ... unless you don't talk about the xwiki Scheduler ? [2]
[2] - http://extensions.xwiki.org/xwiki/bin/view/Extension/Scheduler+Application
=>My script is launch
This test doesn't work #if (xcontext.get("source") != $null)
Anyway you miss the '$' here --> "$xcontext.get("source") ..." Personnally I usually prefer to write: #if ("$!xcontext.get('source')" != "") ... but it's a matter of taste...
#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 <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]
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 <[email protected]> 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/Conte...
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/Conte... 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
(just because I see that syntax issue): On 08/01/2014 03:42 PM, Pascal BASTIEN wrote:
This test doesn't work #if (xcontext.get("source") != $null) #set ($Source = "xcontext.get("source")") #else #set ($Source = "SandboxTemplate") #end
Thats because $null is not the Java null, but "something undefined" A few options to check for null are given here: http://wiki.apache.org/velocity/CheckingForNull (however XWiki does not have that $null-tool installed and the other stuff mentioned from Approach 4 down, so you might try "Approach 3" there) (and there a few '$' in front of xcontext missing ;) Clemens
2014-08-01 16:26 GMT+02:00 Jeremie BOUSQUET <[email protected]>:
Hi,
2014-08-01 15:42 GMT+02:00 Pascal BASTIEN <[email protected]>:
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()
I would maybe try to replace the "...getRenderedContent()" by an include macro [1] like:
{{include reference="SandboxTemplate.ReinitSandboxMacro"/}}
include macro renders the document in same context as container document.
[1] - http://extensions.xwiki.org/xwiki/bin/view/Extension/Include+Macro
And my SandboxTemplate.ReinitSandboxMacro contain this velocity scipt:
#if ($request.get('source') != $null)
If from outside you use "$xcontext.put", you can't expect it to be available from "$request.get" ;-) You should use "$xcontext.get" here instead.
#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')
From where would come this "confirm" request param ? From a scheduler job there will not be such request parameter ... unless you don't talk about the xwiki Scheduler ? [2]
[2] - http://extensions.xwiki.org/xwiki/bin/view/Extension/Scheduler+Application
=>My script is launch
This test doesn't work #if (xcontext.get("source") != $null)
Anyway you miss the '$' here --> "$xcontext.get("source") ..." Personnally I usually prefer to write:
#if ("$!xcontext.get('source')" != "")
... but it's a matter of taste...
Sorry, not only a matter of taste, that way you check at once if property is null OR empty string. Depends on what you need of course.
#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 <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users < [email protected]> 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 <[email protected]> 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/Conte...
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/Conte... 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
By the way, realizing something, if your objective is to call a macro from velocity to "reinitialize a sandbox", with passing parameters, why don't you just make it a velocity macro ??? In your SandboxTemplate.ReinitSandboxMacro : #macro (reinitSandbox $source $target $doCleanup) ## ... your macro code ... #end And in your scheduler script: {{include reference="SandboxTemplate.ReinitSandboxMacro"/}} ... #reinitSandbox "space1" "space2" "true" You could even make it a wiki macro [1] ... [1] - http://platform.xwiki.org/xwiki/bin/view/DevGuide/WikiMacroTutorial 2014-08-01 16:30 GMT+02:00 Jeremie BOUSQUET <[email protected]>:
2014-08-01 16:26 GMT+02:00 Jeremie BOUSQUET <[email protected]>:
Hi,
2014-08-01 15:42 GMT+02:00 Pascal BASTIEN <[email protected]>:
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()
I would maybe try to replace the "...getRenderedContent()" by an include macro [1] like:
{{include reference="SandboxTemplate.ReinitSandboxMacro"/}}
include macro renders the document in same context as container document.
[1] - http://extensions.xwiki.org/xwiki/bin/view/Extension/Include+Macro
And my SandboxTemplate.ReinitSandboxMacro contain this velocity scipt:
#if ($request.get('source') != $null)
If from outside you use "$xcontext.put", you can't expect it to be available from "$request.get" ;-) You should use "$xcontext.get" here instead.
#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')
From where would come this "confirm" request param ? From a scheduler job there will not be such request parameter ... unless you don't talk about the xwiki Scheduler ? [2]
[2] - http://extensions.xwiki.org/xwiki/bin/view/Extension/Scheduler+Application
=>My script is launch
This test doesn't work #if (xcontext.get("source") != $null)
Anyway you miss the '$' here --> "$xcontext.get("source") ..." Personnally I usually prefer to write:
#if ("$!xcontext.get('source')" != "")
... but it's a matter of taste...
Sorry, not only a matter of taste, that way you check at once if property is null OR empty string. Depends on what you need of course.
#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 <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users < [email protected]> 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 <[email protected]> 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/Conte...
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/Conte... 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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Thxs to all, but I try to explain more clairely :-) From groovy I pass (or not) some parameter at my velocity script and in velocity I simply want to check if my parameter exist or not. For the moment, i manage to writing this dirty code: In scheduler: xcontext.put("source", "SandboxTemplate") xcontext.put("target", "Sandbox") xcontext.put("DoCleanup", "true") xwiki.getDocument("SandboxTemplate.ReinitSandboxMacro").getRenderedContent() In my SandboxTemplate.ReinitSandboxMacro page: ##Script seem to be launch by scheduler then I use Source and Target from groovy script in scheduler #if ($xcontext.get("DoCleanup") == 'true') #set ($Source = $xcontext.get("source")) ##set ($Target = $xcontext.get("target")) #else ##Script is launch manally from this page then I use default value of 'source' and 'target' URL parameter doesn't exist (and/or is null) #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 #end ##Launch the reinit #if ($request.DoCleanup == 'true' || $xcontext.get("DoCleanup") == 'true') [[Return>>ReinitSandboxMacro||queryString="source=$Source&target=$Target"]] #if ($request.debug == 'true') {{info}}**Debug mode activated: no change made.**{{/info}} NB: - #if ("$!xcontext.get('target')" != "") doesn't work - I can't include my page in scheduler because it is in groovy syntax. - I don't want doing a xwiki macro because the code is to dangerous (delete space) - I will try services.component.getInstance solution ________________________________
Here there are: http://extensions.xwiki.org/xwiki/bin/view/Extension/Reinit_Sandbox That's work well now :-) (to manipulate with caution) ________________________________ De : Pascal BASTIEN <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Vendredi 1 août 2014 17h08 Objet : Re: [xwiki-users] How to check $xcontext.get(xxxx) is empty? Thxs to all, but I try to explain more clairely :-) From groovy I pass (or not) some parameter at my velocity script and in velocity I simply want to check if my parameter exist or not. For the moment, i manage to writing this dirty code: In scheduler: xcontext.put("source", "SandboxTemplate") xcontext.put("target", "Sandbox") xcontext.put("DoCleanup", "true") xwiki.getDocument("SandboxTemplate.ReinitSandboxMacro").getRenderedContent() In my SandboxTemplate.ReinitSandboxMacro page: ##Script seem to be launch by scheduler then I use Source and Target from groovy script in scheduler #if ($xcontext.get("DoCleanup") == 'true') #set ($Source = $xcontext.get("source")) ##set ($Target = $xcontext.get("target")) #else ##Script is launch manally from this page then I use default value of 'source' and 'target' URL parameter doesn't exist (and/or is null) #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 #end ##Launch the reinit #if ($request.DoCleanup == 'true' || $xcontext.get("DoCleanup") == 'true') [[Return>>ReinitSandboxMacro||queryString="source=$Source&target=$Target"]] #if ($request.debug == 'true') {{info}}**Debug mode activated: no change made.**{{/info}} NB: - #if ("$!xcontext.get('target')" != "") doesn't work - I can't include my page in scheduler because it is in groovy syntax. - I don't want doing a xwiki macro because the code is to dangerous (delete space) - I will try services.component.getInstance solution ________________________________ _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (4)
-
Clemens Klein-Robbenhaar -
Jeremie BOUSQUET -
Pascal BASTIEN -
Thomas Mortagne