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/Context.html#get%28java.lang.String%29
>>>
>>> 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/Context.html#get%28java.lang.String%29
>>> 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
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users