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
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to