Hi,
I want to resurface this question in case it is something that could be addressed in the
2.0 release. I have a macro that requires some js support (jquery) and would thus like to
have additional files referenced in the head section of the page when the macro is used.
It was suggested that I could specify dependencies of css and js files for a macro by
using getPluging("jsfx") and invoking the use method.
From what I can tell this method does not work so
I'm wondering if the 'context' obtained as suggested is not the proper context
to add additional elements to the rendered page.
Here is what I've done:
To get the context, I added this:
@Requirement
private Execution execution;
And then in my macro execution method I added the following:
ExecutionContext executionContext = execution.getContext();
XWikiContext context = (XWikiContext)
executionContext.getProperty("xwikicontext");
XWiki xwiki = context.getWiki();
AbstractSkinExtensionPlugin plugin = (AbstractSkinExtensionPlugin)
xwiki.getPlugin("jsfx", context);
plugin.use("/foo/bar.js",context);
When I utilize this from my macro execution callback it doesn't emit any code in the
header. (using jsfx as a velocity macro does work though).
Is the context obtained via this method the right one or is there a different one somehow
attached to the rendering agent?
Thanks,
Glenn