On Thu, Sep 25, 2014 at 11:18 AM, Pascal BASTIEN
<[email protected]> wrote:
> "it's a kind of magic" for  $stringtool :-)
>
> ... but I didn't manage to use $user.getProperty('email').value or 
> $user.getValue('email')
>
> I try this:
> {{velocity}}
>
> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and 
> obj.className='XWiki.XWikiUsers'")
> #set ($allUsers = $xwiki.searchDocuments($sql))
> #foreach ($user in $allUsers)
>   ##cut ...
>
>   #if ($email != 'mailto:')
>     ## $user -> $email

>     $user -> $user.getProperty('email').value - $user.getValue('email')

You can always do $someVariable.class.name to see the Java class name
and then to look for the corresponding javadoc to see the available
method. In this case, $user is a plain Java string so it doesn't have
the 'getProperty' method. If you don't believe me, look for
'searchDocuments' in
http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?api=xwiki&xpage=embed

You need a Document object. See
http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?api=doc&xpage=embed
which has 'getValue'.

#set ($userDoc = $xwiki.getDocument($user))
$user.getValue('email')

>   #end
> #end
>
> {{/velocity}}
>
> and this:
>
> {{velocity}}
> #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and 
> obj.className='XWiki.XWikiUsers'")
> #set ($allUsers = $xwiki.searchDocuments($sql))
> #foreach ($user in $allUsers)

>   #set ($MyUser = $xwiki.getUser("$user"))

getUser return an object of type User,
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/User.html
, which doesn't have any getProperty or getValue method but has
getEmail. You really need to check the type of objects you are using.

>
>  #if ($email != 'mailto:')
>     ## $user -> $email
>     $user -> $MyUser.getProperty('email').value -  $MyUser.getValue('email')
>   #end
> #end
>
> {{/velocity}}
>
> without success :-(
>
>
>
>
> ________________________________
>  De : "Guillaume "Louis-Marie" Delhumeau" <[email protected]>
> À : XWiki Users <[email protected]>
> Envoyé le : Jeudi 25 septembre 2014 9h19
> Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6?
>
>
> 2014-09-24 22:27 GMT+02:00 Sergiu Dumitriu <[email protected]>:
>
>> On 09/24/2014 10:15 AM, Pascal BASTIEN wrote:
>> > Hello,
>> >
>> > (freely inspired/adapted by:
>> http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent)
>> and
>> http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGroup+velocity
>> (Sergiu)
>> >
>> > Some questions:
>> > to replace some text in velocity, I used $text.replaceAll(xxx,yyy).
>> > Are they a way to use StringUtils tools in velocity?
>> >
>> http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/commons/lang3/StringUtils.html
>> > If yes, how?
>>
>> Yes, $stringtool
>>
>> > I failed to get email adress with $userdoc.display("email","view",$user)
>> function but without "mailto:"; prefix ...
>> >
>> http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Document.html#display%28java.lang.String,%20java.lang.String,%20com.xpn.xwiki.api.Object,%20java.lang.String%29
>>
>> Use $user.getProperty('email').value to access the raw value, display
>> methods generate HTML code.
>>
>
> Since 6.2, you can do $user.getValue('email') :)
>
>
>>
>> > Are they a tip with wrappingSyntaxId value? or I must use regexp like i
>> did?
>> >
>> > If there are too much email I don't know if my macro is safe... (Perhaps
>> there are a way to insert a sleep instruction in velocity?)
>> >
>> > Thxs
>> >
>>
>> --
>> Sergiu Dumitriu
>> http://purl.org/net/sergiu
>> _______________________________________________
>> users mailing list
>> [email protected]
>> http://lists.xwiki.org/mailman/listinfo/users
>>
>
>
>
> --
> Guillaume Delhumeau ([email protected])
> Research & Development Engineer at XWiki SAS
> Committer on the XWiki.org project
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
> _______________________________________________
> 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