On May 14, 2009, at 7:31 PM, <glenn_engel(a)agilent.com> <glenn_engel(a)agilent.com
wrote:
-----Original Message-----
From: devs-bounces(a)xwiki.org [mailto:devs-bounces@xwiki.org] On
Behalf
Of Vincent Massol
Sent: Thursday, May 14, 2009 9:55 AM
To: XWiki Developers
Subject: Re: [xwiki-devs] Macro requiring js/css
On May 14, 2009, at 6:54 PM, Vincent Massol wrote:
On May 14, 2009, at 6:21 PM, <glenn_engel(a)agilent.com>
<glenn_engel(a)agilent.com
wrote:
>
>> -----Original Message-----
>> From: devs-bounces(a)xwiki.org [mailto:devs-bounces@xwiki.org] On
>> Behalf
>> Of Vincent Massol
>> Sent: Thursday, May 14, 2009 8:46 AM
>> To: XWiki Developers
>> Subject: Re: [xwiki-devs] Macro requiring js/css
>>
>> Hi Glenn,
>>
>> The solution is to use a Javascript Extension (JSX).
>> See
>>
http://platform.xwiki.org/xwiki/bin/view/DevGuide/SkinExtensionsTutoria
> l
>
> Then you put the $jsx.use in your java macro.
This looks promising. From the context of a java macro is there
any way to use the $jsx type references?
You'll need to create a MacroBlock with a name of velocity.
but in any case you'll need to put you Javascript extension object in
a wiki page.
I wonder if we're looking at the wrong solution. In this case I
want to include a javascript resource file such as jQuery.js so what
I really want is to specify a script tag to be added to the header
rather than an embedded javascript extension object content.
If you look at the xwiki template that creates the header you'll see
that it has some lines to add all SSX, LSX and JSX objects that exist
in wiki pages. So using a JSX, SSX and LSX is the current way to add
stuff in the header (unless you provide a custom template of course
but then you'll have to maintain it or merge it with new features when
new versions of XWiki are released).
Hope it helps,
-Vincent
I suppose I could look at the jsx extension code to
see how this is
done as it is clearly doing this somehow?
>
> -Vincent
>
>>
>>
>> -Vincent
>>
>>> It looks like the only thing a macro can do is return a List<Block>
>>> instance so I'm not sure it can affect the system header includes?
>>> Using a velocity page could work but seems klunky to have a plugin
>>> import pages into the wiki just to get a macro.
>>>
>>>>
>>>> In the near future (2.0M1), you'll be able to write XWiki 2.0
> syntax
>>>> macros in wiki pages so it'll be more easy to write very UI-
> oriented
>>>> macros.
>>>>
>>>> Of course you can also write your macro as a Velocity macro right
>>>> now
>>>> in a Wiki page and attach the JXS object to that page.
>>>>
>>>> -Vincent
>>>>
>>>> On May 14, 2009, at 5:31 PM, <glenn_engel(a)agilent.com>
>>>> <glenn_engel(a)agilent.com
>>>>> wrote:
>>>>
>>>>> I have a java macro that requires the page to include an external
>>>>> js
>>>>> (e.g. jQuery) that works best if included in the head section of
>>>>> the
>>>>> document. Is there a way for a macro to trigger inclusion of
>>>>> resources like this to be included in the page header? In
>>>>> confluence this was done by having a #requireResource statement
>>>>> in a
>>>>> velocity template included by the macro.
>>>>>
>>>>>
>>>>>
>>>>> How can this be done in xwiki?