PhaseListener

Identifier:
org.eclipse.rap.ui.phaselistener

Since:
RAP 1.0

Description:
The extension point is used to register a PhaseListener implementation. PhaseListeners are objects that are registered to be notified at the beginning and ending of each phase of the request processing lifecycle (see LifeCycle). Extensions should provide a class that implements org.eclipse.rap.rwt.lifecycle.PhaseListener.

Configuration Markup:

<!ELEMENT extension (listener+)>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED

>


<!ELEMENT listener EMPTY>

<!ATTLIST listener

class CDATA #REQUIRED

>


Examples:

<extension
    id="org.eclipse.rap.demo.phaselistenerextension"
    point="org.eclipse.rap.ui.phaselistener">
  <entrypoint
      id="org.eclipse.rap.demo.phaselistener"
      class="org.eclipse.rap.demo.DemoPhaseListener" />
</extension>

API Information:
RWT divides the life cycle of an HTTP request into different phases that are executed sequentially. Each phase has its special purpose and creates the prerequisites needed by the following phases for proper execution. A PhaseListener has to implement the org.eclipse.rap.rwt.lifecycle.PhaseListener interface.

import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.lifecycle.*;

public class DemoPhaseListener implements PhaseListener {

  public void beforePhase( PhaseEvent event ) {
    // ...
    RWT.getLifeCycle().removePhaseListener( this );
  }

  public void afterPhase( final PhaseEvent event ) {
    // ...
  }

  public PhaseId getPhaseId() {
    return PhaseId.RENDER;
  }
}
As PhaseListeners are attached to the RWT lifecycle and thus available globally, you need to make sure to remove them properly if you do not need them anymore (see RWT.getLifeCycle().removePhaseListener(). In case that the PhaseListener needs to access any UI-related objects (e.g. Widgets), you have to make sure that you compare the current display with the one attached to the current session.


Copyright (c) 2007, 2013 EclipseSource and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html