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?

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:

#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
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to