Hi Gerritjan,

On 18 Jan 2016 at 09:34:22, Gerritjan Koekkoek 
(gerrit...@cdlsworld.org(mailto:gerrit...@cdlsworld.org)) wrote:

> Hi
>  
>  
> I wonder if it is possible to use velocity data-types (Number, Date/Time, 
> Array or List, Object) in the parameters field of a UIExtension.
>  
>  
> I get the impression it is always considered as string and we have to do a 
> conversion?

I’ve updated the UIX Module documentation at
http://extensions.xwiki.org/xwiki/bin/view/Extension/UIExtension+Module#HMoreDetails

So yes, the parameters field can contain velocity.

> Following example (for a List of items in a Array)
>  
> cdls.try.abc has the following parameters:
>  
>  
> label=abc
>  
> target=Sandbox.try2
>  
> icon=gerritjan.png
>  
> test=["Item1", 'item2', "item3"]
>  
>  
> {{velocity}}
>  
> $services.uix.getExtensions("cdls.try.abc")
>  
>  
> #foreach ($extension in $services.uix.getExtensions("cdls.try.abc"))
>  
> $services.rendering.render($extension.execute(), 'xhtml/1.0')
>  
> #set($paramlist=$extension.getParameters().get('test'))
>  
> #end
>  
>  
> paramlist is String?: $paramlist.class
>  
>  
> ##Would like it to be a list of items, but now I have to use velocity string 
> functions to create the list...
>  
> #set($paramlistLengthMinusOne = $paramlist.length() - 1)
>  
> #set($items = $paramlist.substring(1, $paramlistLengthMinusOne).split(","))
>  
>  
> #foreach($item in $items)

[snip]

That’s correct, UIX parameters are not typed (they’re strings).

However you can simplify a lot your velocity code.

In the UIX:
test=item1, item2, item3

In the calling code:
#set ($paramlist = $extension.getParameters().get('test'))
#set ($items = $stringtool.split($paramList, “ ,”))
…

Thanks
-Vincent

> Gerritjan Koekkoek
> Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS

_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to