Is it possible to call a soy template from an event Listener? I am working on a blueprint plugin that forces the user to add labels to the page before saving the page. So one of my approaches for that is call the exact dialog box that we get when we try to add labels to the page, but that dialog box should pop up when the use presses the save button on the page. So basically, it should be like this :
public class PageCreatedListener implements DisposableBean { protected EventPublisher eventPublisher; private final LabelManager labelManager; private final PageManager pageManager; private final Logger log; public PageCreatedListener(EventPublisher eventPublisher, LabelManager labelManager, PageManager pageManager) { this.eventPublisher = eventPublisher; eventPublisher.register(this); this.labelManager = labelManager; this.pageManager = pageManager; log = LoggerFactory.getLogger(PageCreatedListener.class); } @EventListener public void pageCreateFromTemplateEvent(PageCreateEvent event) { /* Call the soy template or the dialog box that * asks the user to add labels from here * Is this possible? */ } @Override public void destroy() throws Exception { // TODO Auto-generated method stub } }
No, you've got the wrong end of the stick here.
The listener is really for behind the scenes events and cannot display a thing to the end user.
An example story for an event listener would be:
As a user, I wish Confluence to email a mailing list each time I create a new page.
The PageCreateListener could then send an email in the background for each new page created.
What you're looking for is to modify the behaviour of the Confluence Editor so that a page cannot be saved until a certain number of labels have been added.
As you're using Blueprints, your page will likely already have your Blueprint specific label attached. You need to check for this label on page save and then pop up the labels dialog.
Hope this helps ;)
---
Aside: You could call a soy template from the event listener for example to format an HTML email. You'd need the SoyTemplateRenderer e.g.
<component-import key="soyTemplateRenderer" interface="com.atlassian.soy.renderer.SoyTemplateRenderer"/>
Thanks a lot David!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.