How to include another macro into my plugin code?

I am working on a plugin that helps embedding images into a page. When the image cannot be found, I currently just render some HTML code like “

[Error]: Could not find diagram.

” inside the execute() method of my Macro.
It would be much nicer to display this in form of a warning, tip or error macro. How can I insert other macros inside mine?

There are more than likely a few different ways you can do it.

You can create the storage format version of the info, error etc. and use something like: XhtmlContent (Atlassian Confluence 5.9.7 API) to convert the storage format (in your backend code) into HTML and return that. This is definitely more useful for complicated macros.

For error messages though, you could always just put the correct AUI css classes to get pretty close, with very little effort: Messages - AUI Documentation

1 Like