cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Can we register a listener for any event of a specific object?

vkhole-2
2-Guest

Can we register a listener for any event of a specific object?

eg. listener service should be called for any event occurring on wtpart or a different listener should be called for any event occurring on wtdocument

2 REPLIES 2
mgupta-2
6-Contributor
(To:vkhole-2)

Yes you can..

You just need to implement the performStartupProcess() and in that method you can control which object type and event should be invoked.

eg.

protected void performStartupProcess() throws ManagerException

  {

  try

  {

getManagerService().addEventListener(new ServiceEventListenerAdapter( this.getConceptualClassname() )

  {

                public void notifyVetoableEvent( Object event ) throws WTException,PropertyVetoException,WTPropertyVetoException

                {

                WorkInProgressServiceEvent persistenceEvent = (WorkInProgressServiceEvent)event;

  //System.out.println("\n\n .performStartupProcess() starting for POST_CHECKIN..");

                if( persistenceEvent.getEventTarget() instanceof WTPart)

  {

  Object object = persistenceEvent.getEventTarget();

  //handleUploadEvent(object);

  if(enablePostCheckIn.equalsIgnoreCase("true"))

  {

  handlePostCheckInEvent((WTPart)object);

  }

}

}

},WorkInProgressServiceEvent.generateEventKey(WorkInProgressServiceEvent.POST_CHECKIN));

Thanks a lot Mahesh, il implement it and let you know the updates

Top Tags