Hi
2014-10-02 2:23 GMT+02:00 Bryn Jeffries <bryn.jeffries(a)sydney.edu.au>au>:
I'm appreciate some pointers on getting started on
writing an extension
component that retrieves data from an external database and presents it as
a table. I have reviewed a lot of the available documentation, but must
admit to getting a little lost with the various changes in standards, as a
lot of the available code and documentation describes macros, which I
believe are now deprecated in favour of components.
There is a lot of options.
You can either:
- write a new component indeed, and a script service to expose it to the
scripting languages that we have on XWiki:
http://extensions.xwiki.org/xwiki/bin/view/Extension/Script+Module
- write it directly in Groovy inside the wiki:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting
My extension already does something similar, see:
http://extensions.xwiki.org/xwiki/bin/view/Extension/SQL+Tools
I am happy creating a new component using the Maven archetype, and writing
the necessary code to retrieve data from the external database. What I
would like help with are:
1) How can I get the current user, so that I can use this contextual
information in my query?
You have this information in the XWikiContext object, that you can inject
in your component via a provider. (like this:
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwi…
)
If you are scripting, it is $xcontext.user.
2) How should I return the tabular data?
I'm sure these are very naïve questions, but please take pity on me and by
all means point me at the relevant documentation if it exists already.
Maybe you should return a Map that you then display with some velocity code
in a page.
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
I hope it helps,
--
Guillaume Delhumeau (gdelhumeau(a)xwiki.com)
Research & Development Engineer at XWiki SAS
Committer on the
XWiki.org project