[xwiki-users] Data-Types in UIExtension parameters
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? 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) <h1>"$item.replace('"',"")"</h1> #end {{/velocity}} Gerritjan Koekkoek Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS Visit our website<http://www.cdlsworld.org> Facebook<https://www.facebook.com/gerritjan.koekkoek> email<[email protected]>
Hi Gerritjan, On 18 Jan 2016 at 09:34:22, Gerritjan Koekkoek ([email protected](mailto:[email protected])) 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#HMor... 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
participants (2)
-
Gerritjan Koekkoek -
vincent@massol.net