Hi, 

thanks everyone for all those usefull informations, i think with those + source 
codes from xwiki platform, i have everything i need to get started :) 


David Delbecq 

----- Mail original -----

De: "Marius Dumitru Florea" <[email protected]> 
À: "XWiki Developers" <[email protected]> 
Envoyé: Mercredi 13 Juin 2012 09:30:34 
Objet: Re: [xwiki-devs] Some quesiton regarding development of xwiki macro / 
extensions / plugins 

On Wed, Jun 13, 2012 at 1:48 AM, Sergiu Dumitriu <[email protected]> wrote: 
> On 06/12/2012 09:46 AM, David Delbecq wrote: 
>> 
>> Hello, 
>> 
>> To customize our entreprise wiki, we have identified a few plugins / 
>> macros that we need to develop. I have checked the online xwiki 
>> documentation / tutorial, but i find them quite uncomplete, so here i am 
>> with my questions :) 
>> 
>> 
>> 1) It is my understanding that, if my macro need some specific javascript 
>> (eg jquery.js) and css, i must use xwiki skin extension. While i can find 
>> easily how to create xwiki velocity code that use those extension, i found 
>> no explanation on how to do this in java from within "public List<Block> 
>> execute(T parameters, String content, MacroTransformationContext context)"? 
>> Where can i find example of embedding javascript/css inside a java macro jar 
>> or xar? 
> 
> 
> You declare a dependency on the org.xwiki.platform:xwiki-platform-skin-api 
> module in your project, and you declare a dependency on one or more 
> org.xwiki.skinx.SkinExtension fields with the right hint. For example: 
> 
> @Inject 
> @Named("jsrx") 
> private SkinExtension jsrx; 
> 
> Then you can call jsrx.use("jquery.js") if that file is packaged as a 
> resource whenever your macro is used. 
> 
> If you'r 
> 
> 
>> 2) Extensions are provided as xar, maven archetype for xwiki java macro 
>> generates a .jar. How do i generate a xar with maven so that in one archive 
>> i have both my macro, the css and the js? 
> 
> 
> Not true, extensions can be both jars or xars, depending on what kind of 
> extensions they are. If you're deploying a java macro, then it's right to 
> have a jar extension. A xar is used when you're providing wiki documents 
> that should be installed in the wiki. 
> 
> 
>> 3) Most extension referenced on xwiki main site are open source, but where 
>> are the source? I can only find the compiled xar files on download 
> 
> 
> A xar is just a zip file holding wiki documents, and you can always edit 
> those wiki documents to see their "source". A xar is both the source and the 
> binary. 
> 
> Some extensions do have a separate link to a repository if they have one, 
> especially those hosted on the official xwiki or xwiki-contrib repositories. 
> 
> 
>> 4) Is there some recommanded way to pass complex parameters to macros? I 
>> need to create some dynamic menu that will get as parameter a list of node + 
>> links + icon to show + subnodes + for each subnodes icons / links + 
>> subsubnode etc. Is it good practice to just put some kind of json in the 
>> body of macro, something like 
>> 
>> {{mymenu width="200px"}} 
>> [ 
>> { name: "node1", link: "MySpace.MyPage1", icon: "somelinktoanattachement"} 
>> , 
>> { name: "node2", link: "MySpace.MyPage2", icon: 
>> "somelinktoanattachement"}, 
>> { name: "node3", link: "MySpace.MyPage3", submenu: [ 
>> { name: "node3.1", link: "MySpace.MyPage31", icon: 
>> "somelinktoanattachement"}, 
>> { name: "node3.2", link: "MySpace.MyPage32", icon: 
>> "somelinktoanattachement"} 
>> ] 
>> } 
>> ] 
>> 
>> {{/mymenu}} 
> 
> 
> Unfortunately, macro calls are in text mode, so you don't have much of a 
> choice. 
> 
> You could define a variable somewhere in Velocity and then read it in Java 
> from the VelocityContext, but that's not very safe and might break in the 
> future. 
> 
> 
>> And in this case, are there already some stock xwiki methode to transform 
>> json into objet array? 
> 
> 
> I'm not sure of the status, but there was a proposal recently to include a 
> JSoN tool in the platform. I think it wasn't committed yet, 

It was committed, 
http://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity+Module#HJSONTool 
, but it is useful in Velocity code. For Java code you should use 
directly the available JSON library (e.g. json-lib as suggested by 
Thomas). 

Hope this helps, 
Marius 

> 
> Reading from http://markmail.org/message/k4izx6re4lvdynx3 I think that you 
> should use the Jackson library, available as a maven dependency from 
> http://search.maven.org/#search|ga|1|a%3A%22jackson-core-lgpl%22 
> 
>> Thank you, 
>> 
>> David Delbecq 
> 
> 
> -- 
> Sergiu Dumitriu 
> http://purl.org/net/sergiu/ 
> 
> 
> 
> _______________________________________________ 
> devs mailing list 
> [email protected] 
> http://lists.xwiki.org/mailman/listinfo/devs 
_______________________________________________ 
devs mailing list 
[email protected] 
http://lists.xwiki.org/mailman/listinfo/devs 

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to