hello,
I finally found the way of using JSX with Velocity variables :)
I was defining the custom Velocity variables in the doc containing the JSX
object and it doesn't work. These variables must be defined inside the JSX
object code because the Velocity context is specific to this code
interpretation.
But in my case, I really need to use $xwiki.jsx.use() with some custom
parameters since my javascript requires this customization to work.
Basic velocity context with $xwiki, $doc etc... is too blank to help me.
I think being able to pass some custom parameters to JSX could be really
practical in many cases (as explained in the
http://dev.xwiki.org/xwiki/bin/view/Design/SkinExtensions)
Don't see very big security issues but you may find some :)
I propose to manage this using simple HTTP parameters while calling
jsx.use() in order to provision the $request velocity variable with custom
parameters.
For example:
$xwiki.jsx.use("myJSXdoc?param1=value1¶m2=value2¶m3=value3")
Then in myJSXdoc, you create a JSX object with code looking like:
#set($param1 = $request.get("param1"))
#set($param2 = $request.get("param2"))
#set($param3 = $request.get("param3"))
doit()
{
dosomething("${param1}");
dosomething2("${param2}");
dosomething3("${param3}");
}
The code patch is really simple.
Just a modification of:
public String getLink(String documentName, XWikiContext context) in
skinx.jsSkinExtensionPlugin in order to create a link such as:
<script src="
/xwiki/bin/jsx/myspace/myJSXdoc?param1=value1¶m2=value2¶m3=value3"
type="text/javascript">
regards
Pascal