Calling a Soy template from a Listener

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;
	        this.labelManager = labelManager;
	        this.pageManager = pageManager;
	        log = LoggerFactory.getLogger(PageCreatedListener.class);
	 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?

	public void destroy() throws Exception {
		// TODO Auto-generated method stub


1 answer

1 accepted

0 votes
Accepted answer
David Simpson Community Champion Feb 03, 2014

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=""/>

Thanks a lot David!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published 10 hours ago in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

88 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you