I think I just had an aha moment working with my first panel. The wiki text for the
panel has nothing to do with how it is displayed in the sidebar but is just a convenience
for editing the Panels.PanelClass object. I had most of my code in the PanelClass object
content but had put the xwiki.jsx references in the wiki text portion so it worked fine
when editing the panel but would not work on the sidebar. Seems obvious now...
--
Glenn
From: ENGEL,GLENN (A-Labs,ex1)
Sent: Wednesday, May 27, 2009 3:06 PM
To: XWiki Developers
Subject: RE: [xwiki-devs] Macro requiring js/css
I wasn't able to look at the details of these pages since I don't have edit rights
but I assume you're using the $xwiki.jsx.use technique.
Perhaps I'm over the line but I have a panel I'm trying to add that requires
javascript. If I use the $xwiki.jsx.use() technique it works fine when viewing the panel
after editing but when it gets added to the site side-panel the javascript is no longer
included.
I must say adding javascript includes to pages is quite difficult and hit and miss.
Are there any panels that use javascript that isn't inline ?
--
Glenn
From: Niels Mayer [mailto:nielsmayer@gmail.com]
Sent: Friday, May 22, 2009 6:16 PM
To: XWiki Developers; ENGEL,GLENN (A-Labs,ex1)
Subject: Re: [xwiki-devs] Macro requiring js/css
I'm not having problems w/ JSX.... :-)
It helps to "inline" jquery code directly if following code depends on jquery
already being loaded. If you refer to it to it in a script tag it loads after you need
it.. See
javascript magic/hack happening in these:
http://nielsmayer.com/xwiki/bin/view/Macros/jQuery
http://nielsmayer.com/xwiki/bin/view/Macros/Exhibit
http://nielsmayer.com/xwiki/bin/view/Macros/Timeline
usage:
http://nielsmayer.com/xwiki/bin/view/Main/SiteTimeline
http://nielsmayer.com/xwiki/bin/view/Exhibit/Presidents4
Niels
http://nielsmayer.com
On Tue, May 19, 2009 at 11:22 AM, <glenn_engel(a)agilent.com> wrote:
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
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs