Event Handler not working on second time | Community
Skip to main content
AEMLearner-1989
Level 4
August 3, 2017

Event Handler not working on second time

  • August 3, 2017
  • 1 reply
  • 6736 views

Hi Team,

I am trying to create a event handler for deleting a page.First time ,  its calling up... but second time its not calling handleEvent() method..any clue??

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

smacdonald2008
Level 10
August 3, 2017

What API are you using?

AEMLearner-1989
Level 4
August 3, 2017

Simple code snippet:

@Component(immediate = true)

@Service

@Property(name = EventConstants.EVENT_TOPIC, value = "com/day/cq/wcm/core/page")

public class SimpleResourceListener implements EventHandler{

  public SimpleResourceListener(){

  System.out.println("inside construc");

  }

  private Logger log =LoggerFactory.getLogger(this.getClass());

  public void handleEvent(Event event) {

  // TODO Auto-generated method stub

  System.out.println("inside hanlder");

  }

Now when I create a page, this handler reacts and logs the string "inside handler". Now when I activate the page second or third time, the Event handler does not react

viveksachdeva
Community Advisor
Community Advisor
August 4, 2017

I tried your code on 6.3.. The handlers are getting triggered correctly. When you say " I activate the page second or third time, the Event handler does not react", do you make any change before activating the page again?

When there is no change, activation is never really triggered, so corresponding event handle should not be called anyway