On Thu, Feb 11, 2010 at 13:25, Anamaria Stoica <anam.stoica(a)gmail.com> wrote:
Hi,
I have 2 questions related to Macros:
1/ How can I tell of which type is a macro (Wiki or Java), if I have its
macro descriptor/id?
All wiki macros implements
org.xwiki.rendering.macro.wikibridgeWikiMacro so you can do an
instanceof on the Macro component instance.
2/ How can I get the wiki page with the XWiki.WikiMacroClass for a given
Wiki Macro, if I have
its descriptor/id?
So far, I couldn't think of anything better than doing a HQL for the
document with a XWiki.WikiMacroClass
object with the property macroId set to the one I'm looking for. Code
snippet follows:
There is no other way i think.
Maybe we should add something like WikiMacro#getEntityReference or
WikiMacroManager#getMacros.
#set($macros = $gadgets.getMacroDefinitions())
#foreach($m in $macros)
#set($hql = "select doc.fullName from XWikiDocument doc, BaseObject obj,
StringProperty prop where
doc.fullName=obj.name and obj.className='XWiki.WikiMacroClass' and
prop.id.id=obj.id and prop.name='id'
and prop.value='${m.getMacroId().id}'")
#set($results = $xwiki.search($hql))
#if($results.size() > 0)
#set($macroDoc = $results.get(0))
...
, $gadgets.getMacroDefinitions() - is a custom component which returns a
list of
org.xwiki.rendering.macro.descriptor.MacroDescriptor's with all the macros
in the wiki
Thanks,
Anamaria
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Thomas Mortagne