This documentation relates to the latest version of Confluence.
If you are using an earlier version, please go to the documentation home page and select the relevant version.
This is a constantly updated FAQ listing questions and answers asked by people developing Confluence plugins and working with the Confluence code base in general. For general questions, check Confluence Main FAQ.
If you have a question, please ask it as a comment and someone from Atlassian will reply. Comment threads will gradually be merged back into this FAQ as needed. Please try to be as specific as possible with your questions.
h3 QUESTION: How to access the renderContext of a decorator
In the main.vmd, I ...
h3 QUESTION: How to access the renderContext of a decorator
In the main.vmd, I have a section that I would like to render as wiki text, in order to do this I need access to a renderContext to pass in to a helper.
Charles has said that it is possible, but heavily discouraged it. With that in mind, I would still like to know how to do it (or an alternative method to achieve what I want). See mail 133426.
I'm not sure this qualifies as an FAQ.
You can get the renderContext out of an...
I'm not sure this qualifies as an FAQ.
You can get the renderContext out of any ContentEntityObject using toRenderContext() (new PageContext(obj) does the same thing). There's no set way in a decorator, however, to say "Get the renderContext of the currently-being-displayed CEO".
I think a more accurate question is, from any given velocity decorator file (glo...
I think a more accurate question is, from any given velocity decorator file (global.vmd, space.vmd, page.vmd ...) - how do I get the currently-being-displayed CEO?
$page gives me the page in side of page.vmd (so I can use $page.toRenderContext() or similar), but of course that doesn't work in space.vmd.
If my question is fundamentally wrong I apologise - what I want to do is 2 fold:
Get hold of the Velocity Context variables so I can parse a custom string, as if it was injected directly into the vmd itself (equivelant of #parse "string-content-instead-of-filename")
Get hold of the Render Context so that the result from the Velocity parsing above can be rendered as wiki markup > html output.
As I said in the previous comment, there's no set way to get the currently-being...
As I said in the previous comment, there's no set way to get the currently-being-displayed CEO in a decorator. It would make sense to have such a method on the theme helper object somewhere. For now, you could try a process of elimination: try in order
$helper.page (which actually returns an AbstractPage which could either be a Page or BlogPost object)
$helper.action.mail
$helper.action.personalInformationEntity
$helper.space.description (This may be not necessarily be what is being viewed, so you might want to skip this as a fallback)
If all these return null, you're looking at a global page with no space or entity to look at.
In main.vmd, however, you're out of luck. By the time SiteMesh hits main.vmd, most of the context has been lost, except for what has been passed up from the other decorators or templates inside <content> blocks.
QUESTION: How do I persist a "Request" level object?
I am currently using Servl...
QUESTION: How do I persist a "Request" level object?
I am currently using ServletActionContext.getRequest().setAttribute() (and the appropriate getter), however there are cases where the request will not exist (eg: when the macro is rendered from a decorator (like in the LeftNav theme), or when exporting to PDF).
What should I use? Perhaps the RenderContext (or one of its ancestors) should contain the ability to set/get attributes?
If this is the case then I'll file a JIRA support issue.
Dan,
perhaps you can tell us what you are trying to achieve and we can think ab...
Dan,
perhaps you can tell us what you are trying to achieve and we can think about a solution for you problem. However, we probably shouldn't discuss it in this comment thread, so drop us an email.
I have a related question. There seems to be an incompatibility between 1.4 and...
I have a related question. There seems to be an incompatibility between 1.4 and 2.0 in that ServletActionContext.getRequest() returns null in 2.0 in cases that worked in 1.4. For instance if the preview tab is selected, it is null. Interestingly, in a comment where you are allowed to press the preview button, the button works but the preview tab does not (ie. returns null). Why is it incompatible and what recommendations are there for macro writers? Thanks.
The general rule is: assume that ServletActionContext.getAnything() will return ...
The general rule is: assume that ServletActionContext.getAnything() will return null. There are several situations in which macros will be rendered without the ServletActionContext being populated, whether it be because the request hasn't come in via Webwork, as is the case with AJAX requests that are routed through the DWR servlet, or because the request is being rendered for something like an email which doesn't have a web context to begin with.
The ServletActionContext should always be considered a bonus - if it's populated, you can do something useful with it, but you shouldn't count on its existence.
Ok it looks to me like the behavior of AbstractHtmlGeneratingMacro has changed from what it was in 1.3: basically the body that's provided to the macro (through MacroParameter) seems to be raw HTML instead of raw wiki text as in the past. Not sure if this was intended by the Atlassian crew and/or why it was done.
As a result, it seems the only way out is for this macro to be rewritten for 2.x, by extending BaseMacro and use RenderMode.NO_RENDER (ie. no rendering of wiki into HTML).
Am I right about this? If so, it might be worth documenting on this page. I know it wouldn't matter for new macros but it might be useful to know for legacy macros (to determine whether they might have to be rewritten).
No, Confluence wiki format is converted to HTML via regular expressions, not via...
No, Confluence wiki format is converted to HTML via regular expressions, not via parsing. This allows any markup to produce sensible HTML without the problems that a parser would have trying to recover from errors.
Is it possible to access classes from one plugin jar in another? I'm tryin...
Is it possible to access classes from one plugin jar in another? I'm trying to write an extension of another plugin by extending a Base class, but when I try to upload my JAR, I'm getting a ClassNotFoundException. Short of combining the two plugins together, is there any way to access classes written for one plugin in another?
The only way to do this that I'm aware of is for at least one of the plugins to ...
The only way to do this that I'm aware of is for at least one of the plugins to have been installed by putting it into WEB-INF/lib instead of uploading it. So, if plugin-a.jar depends on classes in plugin-b.jar, plugin-b.jar needs to be installed into WEB-INF/lib. If plugin-b.jar also depends on classes in plugin-a.jar, then both plugins will have to be installed into WEB-INF/lib.
This is due to the way the class loader for uploaded plugins works. There are some ideas bouncing around to improve the situation, but the scenario you described is unlikely to be resolved any time soon, unfortunately.
How do I programatically remove and add attachments to a page in Confluence?
&n...
How do I programatically remove and add attachments to a page in Confluence?
Say I use a page as an informal document (i.e., word, excel, powerpoint, etc.) repository. I also have a proper document repository outside of Confluence. How would I update the page in Confluence programatically, containing these documents as attachments, with a new set of attachments?
Comments (62)
Sep 29, 2005
Dan Hardiker says:
h3 QUESTION: How to access the renderContext of a decorator In the main.vmd, I ...h3 QUESTION: How to access the renderContext of a decorator
In the main.vmd, I have a section that I would like to render as wiki text, in order to do this I need access to a renderContext to pass in to a helper.
Charles has said that it is possible, but heavily discouraged it. With that in mind, I would still like to know how to do it (or an alternative method to achieve what I want). See mail 133426.
Oct 03, 2005
Charles Miller says:
I'm not sure this qualifies as an FAQ. You can get the renderContext out of an...I'm not sure this qualifies as an FAQ.
You can get the renderContext out of any ContentEntityObject using toRenderContext() (new PageContext(obj) does the same thing). There's no set way in a decorator, however, to say "Get the renderContext of the currently-being-displayed CEO".
Oct 04, 2005
Dan Hardiker says:
I think a more accurate question is, from any given velocity decorator file (glo...I think a more accurate question is, from any given velocity decorator file (global.vmd, space.vmd, page.vmd ...) - how do I get the currently-being-displayed CEO?
$page gives me the page in side of page.vmd (so I can use $page.toRenderContext() or similar), but of course that doesn't work in space.vmd.
If my question is fundamentally wrong I apologise - what I want to do is 2 fold:
I hope that makes more sense!
Oct 09, 2005
Charles Miller says:
As I said in the previous comment, there's no set way to get the currently-being...As I said in the previous comment, there's no set way to get the currently-being-displayed CEO in a decorator. It would make sense to have such a method on the theme helper object somewhere. For now, you could try a process of elimination: try in order
If all these return null, you're looking at a global page with no space or entity to look at.
In main.vmd, however, you're out of luck. By the time SiteMesh hits main.vmd, most of the context has been lost, except for what has been passed up from the other decorators or templates inside <content> blocks.
Oct 11, 2005
Laura Kolker says:
is 'myObject' supposed to be the class I want to contain autowire objects, or t...Hmm.. I must be missing something. I've tried both:
and I get NullPointerExceptions.
Could you give a more in depth example?
Thanks.
Nov 10, 2005
Dan Hardiker says:
QUESTION: How do I persist a "Request" level object? I am currently using Servl...QUESTION: How do I persist a "Request" level object?
I am currently using ServletActionContext.getRequest().setAttribute() (and the appropriate getter), however there are cases where the request will not exist (eg: when the macro is rendered from a decorator (like in the LeftNav theme), or when exporting to PDF).
What should I use? Perhaps the RenderContext (or one of its ancestors) should contain the ability to set/get attributes?
If this is the case then I'll file a JIRA support issue.
Nov 14, 2005
Jens Schumacher says:
Dan, perhaps you can tell us what you are trying to achieve and we can think ab...Dan,
perhaps you can tell us what you are trying to achieve and we can think about a solution for you problem. However, we probably shouldn't discuss it in this comment thread, so drop us an email.
Cheers,
Jens
Nov 23, 2005
Bob Swift says:
I have a related question. There seems to be an incompatibility between 1.4 and...I have a related question. There seems to be an incompatibility between 1.4 and 2.0 in that ServletActionContext.getRequest() returns null in 2.0 in cases that worked in 1.4. For instance if the preview tab is selected, it is null. Interestingly, in a comment where you are allowed to press the preview button, the button works but the preview tab does not (ie. returns null). Why is it incompatible and what recommendations are there for macro writers? Thanks.
Nov 24, 2005
Charles Miller says:
The general rule is: assume that ServletActionContext.getAnything() will return ...The general rule is: assume that ServletActionContext.getAnything() will return null. There are several situations in which macros will be rendered without the ServletActionContext being populated, whether it be because the request hasn't come in via Webwork, as is the case with AJAX requests that are routed through the DWR servlet, or because the request is being rendered for something like an email which doesn't have a web context to begin with.
The ServletActionContext should always be considered a bonus - if it's populated, you can do something useful with it, but you shouldn't count on its existence.
Dec 03, 2005
Bob Swift says:
Charles, thanks. Seems like ConfluenceMockServletRequest() serves similar purpo...Charles, thanks. Seems like ConfluenceMockServletRequest() serves similar purpose for getting things like context path - getContextPath().
Dec 08, 2005
Bob Swift says:
How do you add a new section to the notation guide? If I don't used an existing...How do you add a new section to the notation guide? If I don't used an existing section (like Advanced) then the macro help doesn't show up anywhere.
Dec 08, 2005
David Peterson [CustomWare] says:
As far as I know, it's currently not possible without source hacking. I've wante...As far as I know, it's currently not possible without source hacking. I've wanted the same thing on several occasions (eg. Scaffolding). Vote here.
Jan 15, 2006
Othman Alaoui says:
The following comments I posted at http://confluence.atlassian.com/display/CONFE...The following comments I posted at http://confluence.atlassian.com/display/CONFEXT/Vote+Macro?focusedCommentId=152965#comment-152965 might be of relevance here:
Am I right about this? If so, it might be worth documenting on this page. I know it wouldn't matter for new macros but it might be useful to know for legacy macros (to determine whether they might have to be rewritten).
Jan 30, 2006
Ersin Er says:
Is there an available BNF/EBNF/or any else grammar for Confluence wiki format ?Is there an available BNF/EBNF/or any else grammar for Confluence wiki format ?
Jan 31, 2006
Tom Davies says:
No, Confluence wiki format is converted to HTML via regular expressions, not via...No, Confluence wiki format is converted to HTML via regular expressions, not via parsing. This allows any markup to produce sensible HTML without the problems that a parser would have trying to recover from errors.
Feb 23, 2006
Brian Sensale says:
Is it possible to access classes from one plugin jar in another? I'm tryin...Is it possible to access classes from one plugin jar in another? I'm trying to write an extension of another plugin by extending a Base class, but when I try to upload my JAR, I'm getting a ClassNotFoundException. Short of combining the two plugins together, is there any way to access classes written for one plugin in another?
Feb 23, 2006
David Peterson [CustomWare] says:
The only way to do this that I'm aware of is for at least one of the plugins to ...The only way to do this that I'm aware of is for at least one of the plugins to have been installed by putting it into WEB-INF/lib instead of uploading it. So, if plugin-a.jar depends on classes in plugin-b.jar, plugin-b.jar needs to be installed into WEB-INF/lib. If plugin-b.jar also depends on classes in plugin-a.jar, then both plugins will have to be installed into WEB-INF/lib.
This is due to the way the class loader for uploaded plugins works. There are some ideas bouncing around to improve the situation, but the scenario you described is unlikely to be resolved any time soon, unfortunately.
Feb 23, 2006
Brian Sensale says:
Thanks...dropping it in web-inf/lib did the trick.Thanks...dropping it in web-inf/lib did the trick.
Apr 04, 2006
Evan Light says:
How do I programatically remove and add attachments to a page in Confluence? &n...How do I programatically remove and add attachments to a page in Confluence?
Say I use a page as an informal document (i.e., word, excel, powerpoint, etc.) repository. I also have a proper document repository outside of Confluence. How would I update the page in Confluence programatically, containing these documents as attachments, with a new set of attachments?
Oct 12
Guy Fraser says:
There are a number of options: WebDAV plugin: Confluence WebDAV Plugin Perl XM...There are a number of options:
WebDAV plugin: Confluence WebDAV Plugin
Perl XML-RPC Client: Perl XML-RPC client
Multiple Attachments Uploader: Multiple Attachments Upload Client
Confluence file uploaded: Confluence File Uploader
Mar 27, 2008
Bob Swift says:
Or Confluence Command Line InterfaceOr Confluence Command Line Interface