A simple LifeCycleListener

package your.pkg.name;

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

public class LifeCycleListener implements PhaseListener {

      private static final long serialVersionUID = 1L;

      public PhaseId getPhaseId() {
        return PhaseId.ANY_PHASE;
    }

    public void beforePhase(PhaseEvent event) {
        System.out.println("START PHASE " + event.getPhaseId());
    }

    public void afterPhase(PhaseEvent event) {
        System.out.println("END PHASE " + event.getPhaseId());
    }

}

Add the following lines to your faces-config

  <lifecycle>
    <phase-listener>your.pkg.name.LifeCycleListener</phase-listener>
</lifecycle>





Put some print statemants into your code and LifeCycleListener displays on the console in which phases of the LifeCycle of an XPage your code is executed.
We used this to identify if / when code is executed multiple times during a partial refresh that was triggered on datasources outside the refreshId

Java
Ulrich Krause
February 20, 2012 4:50 AM
Rating
333

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...