Macros, Velocity and parameters

Hello there

Next step in my xWiki experience: macros …

I tried to create a macro that uses the tree macro inside … rather strange behavior with the empty lines required … however, this is not the question …

The macro has one parameter that I defined as type “java.lang.Integer”.

First challenge:
The parameter is not available after calling
{{tree links=“true”}}

So I had to write

{{velocity}}
#set( $paramLevels = $xcontext.macro.params.levels )
{{/velocity}}

to get it to the global variable scope before using the tree macro … took me some time to figure that out …

Now, using an IF clause did not work with “>”… strange … until I determined that the variable read from the parameter $xcontext.macro.params.levels was of type string.

At the end of the day,

#set( $paramLevels = $xcontext.macro.params.levels )
#set( $levels = 0)
$levels.parseInt( $paramLevels )

did the trick … lot of time spent and a lot learned about Velocity and xWiki

Back to the question: wouldn’t it be great if the parameter type would be inherited by the variable exposed to Velocity?

Thanks

$xcontext.macro.params should definitely take into account the configured type, maybe it was forgotten in Loading.... Would be great if you could report that as a bug.

Done
https://jira.xwiki.org/browse/XCOMMONS-1657